fix: check driver command for adding worker

This commit is contained in:
jialin
2025-10-20 19:11:02 +08:00
parent 9b843151fe
commit 3a7a4ccf30
12 changed files with 162 additions and 61 deletions
@@ -5,6 +5,11 @@
color: var(--ant-color-text-tertiary);
font-size: var(--font-size-base);
> span {
display: flex;
align-items: center;
}
.note-info {
margin-left: 4px;
}
+26 -31
View File
@@ -1,6 +1,7 @@
import AutoTooltip from '@/components/auto-tooltip';
import DropDownActions from '@/components/drop-down-actions';
import IconFont from '@/components/icon-font';
import TagWrapper from '@/components/tags-wrapper';
import ThemeTag from '@/components/tags-wrapper/theme-tag';
import Card from '@/components/templates/card';
import { useIntl } from '@umijs/max';
@@ -89,6 +90,7 @@ const Content = styled.div`
const InfoItem = styled.div`
display: grid;
width: 100%;
grid-template-columns: max-content 1fr;
align-items: center;
gap: 8px;
@@ -103,12 +105,6 @@ const InfoItem = styled.div`
}
`;
const BackendBox = styled.div`
display: flex;
align-items: center;
gap: 8px;
`;
interface BackendCardProps {
onClick?: (data: any) => void;
onSelect?: (item: any) => void;
@@ -151,6 +147,25 @@ const BackendCard: React.FC<BackendCardProps> = ({ data, onSelect }) => {
e.stopPropagation();
};
const renderTag = (item: any) => {
return (
<AutoTooltip
ghost
minWidth={20}
showTitle
title={_.join(data.framework_index_map?.[item], ', ') || false}
>
<ThemeTag
key={item}
style={{ marginRight: 0 }}
color={getGpuColor(item)}
>
{item}
</ThemeTag>
</AutoTooltip>
);
};
const renderFrameworks = () => {
const frameworks = _.keys(data.framework_index_map || {});
@@ -162,31 +177,11 @@ const BackendCard: React.FC<BackendCardProps> = ({ data, onSelect }) => {
{intl.formatMessage({ id: 'backend.availableFrameworks' })}:{' '}
</span>
</span>
<BackendBox>
{_.take(frameworks, 3).map((item: string) => {
return (
<div key={item}>
<AutoTooltip
ghost
minWidth={20}
showTitle
title={
_.join(data.framework_index_map?.[item], ', ') || false
}
>
<ThemeTag
key={item}
style={{ marginRight: 0 }}
color={getGpuColor(item)}
>
{item}
</ThemeTag>
</AutoTooltip>
</div>
);
})}
</BackendBox>
<TagWrapper
gap={8}
dataList={frameworks}
renderTag={renderTag}
></TagWrapper>
</InfoItem>
);
};
+3 -9
View File
@@ -91,20 +91,14 @@ export const gpuColorMap: Record<string, string> = {
rocm: 'volcano',
dtk: 'magenta',
musa: 'cyan',
corex: 'purple'
corex: 'purple',
maca: 'geekblue'
};
export const getGpuColor = (gpuType: string) => {
if (!gpuType) return 'default';
if (gpuType.includes('cann')) return gpuColorMap['cann'];
if (gpuType.includes('cuda')) return gpuColorMap['cuda'];
if (gpuType.includes('rocm')) return gpuColorMap['rocm'];
if (gpuType.includes('dtk')) return gpuColorMap['dtk'];
if (gpuType.includes('musa')) return gpuColorMap['musa'];
if (gpuType.includes('corex')) return gpuColorMap['corex'];
return 'default';
return gpuColorMap[gpuType] || 'default';
};
export const customIcons = [
@@ -12,7 +12,7 @@ type ViewModalProps = {
const AddWorkerCommand: React.FC<ViewModalProps> = ({ registrationInfo }) => {
const code = React.useMemo(() => {
const commandCode = addWorkerGuide['cuda'];
const commandCode = addWorkerGuide['all'];
return commandCode?.registerWorker({
server: registrationInfo.server_url || origin,
tag: '',
@@ -13,9 +13,10 @@ const AddWorkerCommand: React.FC<ViewModalProps> = ({
currentGPU
}) => {
const code = React.useMemo(() => {
const command = addWorkerGuide['cuda'];
return command.checkEnvCommand[provider || ''];
}, [provider]);
const configs = addWorkerGuide['all'];
const command = configs.checkEnvCommand(currentGPU);
return command[provider || ''];
}, [provider, currentGPU]);
return (
<HighlightCode
@@ -26,6 +26,49 @@ interface SupportedHardwareProps {
clickable?: boolean;
}
const GPUsConfigs = {
cuda: {
label: 'NVIDIA',
value: 'cuda',
runtime: 'nvidia'
},
rocm: {
label: 'AMD',
value: 'rocm',
runtime: 'rocm'
},
npu: {
label: 'Ascend',
value: 'npu',
runtime: 'ascend'
},
dcu: {
label: 'Hygon',
value: 'dcu',
runtime: 'dcu'
},
musa: {
label: 'Moore Threads',
value: 'musa',
runtime: 'musa'
},
corex: {
label: 'Iluvatar',
value: 'corex',
runtime: 'corex'
},
cambricon: {
label: 'Cambricon',
value: 'cambricon',
runtime: 'cambricon'
},
metax: {
label: 'MetaX',
value: 'metax',
runtime: 'metax'
}
};
const SupportedHardware: React.FC<SupportedHardwareProps> = ({
onSelect,
clickable,
@@ -30,7 +30,7 @@ const CatalogItem: React.FC<CatalogItemProps> = (props) => {
e.target.src = fallbackImg;
};
const renderTag = (sItem: any) => {
const renderTag = useCallback((sItem: any) => {
return (
<ThemeTag
key={sItem}
@@ -50,7 +50,7 @@ const CatalogItem: React.FC<CatalogItemProps> = (props) => {
{sItem}B
</ThemeTag>
);
};
}, []);
return (
<div
+7 -4
View File
@@ -72,10 +72,15 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
// voxbox is not support multi gpu
const updateGPUSelector = (backend: string) => {
const gpuids = form.getFieldValue(['gpu_selector', 'gpu_ids']) || [];
const gpusPerReplicas =
form.getFieldValue(['gpu_selector', 'gpus_per_replica']) || null;
if (backend === backendOptionsMap.voxBox && gpuids.length > 0) {
return {
gpu_selector: { gpu_ids: [gpuids[0]] }
gpusCountType: gpusCountTypeMap.Auto,
gpu_selector: {
gpu_ids: [gpuids[0]]
}
};
}
return {
@@ -131,9 +136,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
getGPUOptionList({ clusterId: value });
getBackendOptions({ cluster_id: value });
if (scheduleType === ScheduleValueMap.Manual) {
form.setFieldsValue({
gpu_selector: { gpu_ids: [] }
});
form.setFieldValue(['gpu_selector', 'gpu_ids'], []);
}
};
+10 -3
View File
@@ -52,7 +52,6 @@ const ScheduleTypeForm: React.FC = () => {
const form = Form.useFormInstance();
const scheduleType = Form.useWatch('scheduleType', form);
const gpusCountType = Form.useWatch('gpusCountType', form);
const gpuSelectorIds = Form.useWatch(['gpu_selector', 'gpu_ids'], form);
const handleScheduleTypeChange = (value: string) => {
if (value === ScheduleValueMap.Auto) {
@@ -61,9 +60,10 @@ const ScheduleTypeForm: React.FC = () => {
};
const handleGpusCountTypeChange = (val: string) => {
if (val === 'custom') {
form.setFieldValue(['gpu_selector', 'gpus_per_replica'], 2);
if (val === gpusCountTypeMap.Custom) {
form.setFieldValue(['gpu_selector', 'gpus_per_replica'], 1);
}
onValuesChange?.({}, form.getFieldsValue());
};
@@ -91,6 +91,12 @@ const ScheduleTypeForm: React.FC = () => {
onValuesChange?.({}, form.getFieldsValue());
};
const handleOnStepReplica = (value: number | null) => {
if (value === null) {
form.setFieldValue(['gpu_selector', 'gpus_per_replica'], 1);
}
};
return (
<>
<Form.Item name="scheduleType">
@@ -187,6 +193,7 @@ const ScheduleTypeForm: React.FC = () => {
})}
min={1}
step={1}
onChange={handleOnStepReplica}
onStep={handleOnStepReplicaStep}
/>
</Form.Item>
+3 -3
View File
@@ -34,9 +34,9 @@ export const llmInitialValues = {
stop: null,
temperature: 1,
top_p: 1,
max_tokens: null,
frequency_penalty: null,
presence_penalty: null
max_tokens: 1024,
frequency_penalty: 0,
presence_penalty: 0
};
export const advancedFieldsDefaultValus = {
+58 -5
View File
@@ -34,6 +34,57 @@ export const status: any = {
[WorkerStatusMap.initializing]: StatusMaps.transitioning
};
export const GPUsConfigs: Record<string, any> = {
cuda: {
label: 'NVIDIA',
value: 'cuda',
runtime: 'nvidia',
driver: 'nvidia-smi'
},
rocm: {
label: 'AMD',
value: 'rocm',
runtime: 'rocm',
driver: 'rocm-smi'
},
npu: {
label: 'Ascend',
value: 'npu',
runtime: 'ascend',
driver: 'npu-smi'
},
dcu: {
label: 'Hygon',
value: 'dcu',
runtime: 'dcu', // TODO: confirm runtime name
driver: 'hy-smi'
},
musa: {
label: 'Moore Threads',
value: 'musa',
runtime: 'mthreads',
driver: 'mthreads-gmi'
},
corex: {
label: 'Iluvatar',
value: 'corex',
runtime: 'corex', // TODO: confirm runtime name
driver: 'ixsmi'
},
cambricon: {
label: 'Cambricon',
value: 'cambricon',
runtime: 'cambricon',
driver: 'cnmon'
},
metax: {
label: 'MetaX',
value: 'metax',
runtime: 'metax',
driver: 'mx-smi'
}
};
export const addWorkerGuide: Record<string, any> = {
mac: {
getToken: 'cat /var/lib/gpustack/token',
@@ -48,7 +99,7 @@ export const addWorkerGuide: Record<string, any> = {
return `Invoke-Expression "& { $((Invoke-WebRequest -Uri 'https://get.gpustack.ai' -UseBasicParsing).Content) } --server-url '${params.server}' --registration-token '${params.token}'"`;
}
},
cuda: {
all: {
getToken:
'Get-Content -Path (Join-Path -Path $env:APPDATA -ChildPath "gpustack\\token") -Raw',
registerWorker(params: {
@@ -69,10 +120,12 @@ export const addWorkerGuide: Record<string, any> = {
--registration-token ${params.token} \\
--worker-ip ${params.workerip}`;
},
checkEnvCommand: {
[ProviderValueMap.Docker]: `nvidia-smi >/dev/null 2>&1 && echo "NVIDIA driver OK" || (echo "NVIDIA driver issue"; exit 1) && docker info 2>/dev/null | grep -q "Default Runtime: nvidia" && echo "NVIDIA Container Toolkit OK" || (echo "NVIDIA Container Toolkit not configured"; exit 1)`,
[ProviderValueMap.Kubernetes]:
'kubectl get runtimeclass nvidia > /dev/null 2>&1 && echo "NVIDIA runtimeclass registered" || (echo "NVIDIA runtimeclass issue"; exit 1)'
checkEnvCommand(gpu: string) {
const config = GPUsConfigs[gpu];
return {
[ProviderValueMap.Docker]: `${config.driver} >/dev/null 2>&1 && echo "${config.label} driver OK" || (echo "${config.label} driver issue"; exit 1) && docker info 2>/dev/null | grep -q "Default Runtime: ${config.runtime}" && echo "${config.label} Container Toolkit OK" || (echo "${config.label} Container Toolkit not configured"; exit 1)`,
[ProviderValueMap.Kubernetes]: `kubectl get runtimeclass ${config.runtime} > /dev/null 2>&1 && echo "${config.label} runtimeclass registered" || (echo "${config.label} runtimeclass issue"; exit 1)`
};
}
},
npu: {