chore: add worker command paramters

This commit is contained in:
jialin
2024-12-23 19:13:55 +08:00
parent 6ce6a932e1
commit 762ab30c71
8 changed files with 94 additions and 28 deletions
+6 -2
View File
@@ -47,10 +47,14 @@ export default {
'Note: <span style="color: #000;font-weight: 600">mytoken</span> is the token obtained in the first step.', 'Note: <span style="color: #000;font-weight: 600">mytoken</span> is the token obtained in the first step.',
'resources.worker.add.step3': 'resources.worker.add.step3':
'After success, refresh the workers list to see the new worker.', 'After success, refresh the workers list to see the new worker.',
'resources.worker.container.supported': 'Do not support windows.', 'resources.worker.container.supported': 'Do not support MacOS or Windows.',
'resources.worker.current.version': 'Current version is {version}.', 'resources.worker.current.version': 'Current version is {version}.',
'resources.worker.driver.install':
'Ensure all necessary drivers and libraries are installed on the system prior to installing GPUStack.',
'resources.worker.select.command': 'resources.worker.select.command':
'Select a label to generate the command and copy it using the copy button.', 'Select a label to generate the command and copy it using the copy button.',
'resources.worker.script.install': 'Script Installation', 'resources.worker.script.install': 'Script Installation',
'resources.worker.container.install': 'Container Installation' 'resources.worker.container.install': 'Container Installation',
'resources.worker.cann.tips':
'Set <span style="color: #000;font-weight: 600">ASCEND_VISIBLE_DEVICES</span> to 0 for a single GPU or to the index range (e.g., 0-7 for 8 GPUs) for multiple GPUs.'
}; };
+6 -2
View File
@@ -46,9 +46,13 @@ export default {
'resources.worker.add.step2.tips': 'resources.worker.add.step2.tips':
'注意:<span style="color: #000;font-weight: 600">mytoken</span> 为第一步获取到的 Token', '注意:<span style="color: #000;font-weight: 600">mytoken</span> 为第一步获取到的 Token',
'resources.worker.add.step3': '成功后,刷新 worker 列表即可看到新的 worker', 'resources.worker.add.step3': '成功后,刷新 worker 列表即可看到新的 worker',
'resources.worker.container.supported': '不支持 Windows', 'resources.worker.container.supported': '不支持 MacOS 和 Windows',
'resources.worker.current.version': '当前版本为 {version}', 'resources.worker.current.version': '当前版本为 {version}',
'resources.worker.select.command': '选择一个标签生成命令并使用复制按钮复制', 'resources.worker.select.command': '选择一个标签生成命令并使用复制按钮复制',
'resources.worker.driver.install':
'在安装 GPUStack 之前,确保系统上安装了所有必需的驱动程序和库',
'resources.worker.script.install': '脚本安装', 'resources.worker.script.install': '脚本安装',
'resources.worker.container.install': '容器安装' 'resources.worker.container.install': '容器安装',
'resources.worker.cann.tips':
'若 GPU 数量为 1,则设 ASCEND_VISIBLE_DEVICES=0;若大于 1,则设为索引范围(如 8 张为 0-7)'
}; };
@@ -1,8 +1,4 @@
import { import { BulbOutlined, QuestionCircleOutlined } from '@ant-design/icons';
BulbOutlined,
QuestionCircleOutlined,
WarningOutlined
} from '@ant-design/icons';
import { useIntl } from '@umijs/max'; import { useIntl } from '@umijs/max';
import { Checkbox, Select, Tooltip } from 'antd'; import { Checkbox, Select, Tooltip } from 'antd';
import _ from 'lodash'; import _ from 'lodash';
@@ -238,7 +234,9 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
modelSource={modelSource} modelSource={modelSource}
></SearchInput> ></SearchInput>
<div className="gguf-tips"> <div className="gguf-tips">
<WarningOutlined className="font-size-14 m-r-5 warning" /> <span className="m-r-5">
{intl.formatMessage({ id: 'common.tips.title' })}
</span>
<span> <span>
{intl.formatMessage({ id: 'models.form.search.gguftips' })} {intl.formatMessage({ id: 'models.form.search.gguftips' })}
</span> </span>
@@ -41,7 +41,7 @@ const AddWorker: React.FC<ViewModalProps> = (props) => {
width={600} width={600}
styles={{ styles={{
body: { body: {
height: 310 height: 410
} }
}} }}
footer={null} footer={null}
@@ -3,7 +3,7 @@ import { getAtomStorage } from '@/atoms/utils';
import HighlightCode from '@/components/highlight-code'; import HighlightCode from '@/components/highlight-code';
import { BulbOutlined, WarningOutlined } from '@ant-design/icons'; import { BulbOutlined, WarningOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max'; import { useIntl } from '@umijs/max';
import { Radio } from 'antd'; import { Button, Radio } from 'antd';
import React from 'react'; import React from 'react';
import { addWorkerGuide, containerInstallOptions } from '../config'; import { addWorkerGuide, containerInstallOptions } from '../config';
import './styles/installation.less'; import './styles/installation.less';
@@ -24,14 +24,17 @@ const AddWorker: React.FC<ViewModalProps> = (props) => {
if (!version || !versionInfo.isProduction) { if (!version || !versionInfo.isProduction) {
version = 'main'; version = 'main';
} }
const commandCode = addWorkerGuide[activeKey];
if (activeKey === 'cuda') { if (activeKey === 'cuda') {
return addWorkerGuide.docker.registerWorker({ return commandCode?.registerWorker({
server: origin, server: origin,
tag: version, tag: version,
token: props.token token: props.token
}); });
} }
return addWorkerGuide.docker.registerWorker({ return commandCode?.registerWorker({
server: origin, server: origin,
tag: `${version}-${activeKey}`, tag: `${version}-${activeKey}`,
token: props.token token: props.token
@@ -40,9 +43,8 @@ const AddWorker: React.FC<ViewModalProps> = (props) => {
return ( return (
<div className="container-install"> <div className="container-install">
<div className="notes"> <ul className="notes">
<span> <li>
1.{' '}
<span> <span>
{intl.formatMessage({ id: 'resources.worker.container.supported' })} {intl.formatMessage({ id: 'resources.worker.container.supported' })}
</span> </span>
@@ -50,18 +52,32 @@ const AddWorker: React.FC<ViewModalProps> = (props) => {
style={{ color: 'var(--ant-color-warning)' }} style={{ color: 'var(--ant-color-warning)' }}
className="font-size-14 m-l-5" className="font-size-14 m-l-5"
/> />
</span> </li>
<span> <li>
2.{' '}
{intl.formatMessage( {intl.formatMessage(
{ id: 'resources.worker.current.version' }, { id: 'resources.worker.current.version' },
{ version: versionInfo.version } { version: versionInfo.version }
)} )}
</span> </li>
<span> <li>{intl.formatMessage({ id: 'resources.worker.select.command' })}</li>
3. {intl.formatMessage({ id: 'resources.worker.select.command' })} <li>
</span> <span>
</div> {intl.formatMessage({ id: 'resources.worker.driver.install' })}
</span>
<WarningOutlined
style={{ color: 'var(--ant-color-warning)' }}
className="font-size-14 m-l-5"
/>
<Button
type="link"
size="small"
href="https://docs.gpustack.ai/latest/installation/installation-requirements/"
target="_blank"
>
{intl.formatMessage({ id: 'playground.audio.enablemic.doc' })}
</Button>
</li>
</ul>
<div className="m-b-20"> <div className="m-b-20">
<Radio.Group <Radio.Group
block block
@@ -74,6 +90,14 @@ const AddWorker: React.FC<ViewModalProps> = (props) => {
size="small" size="small"
/> />
</div> </div>
{activeKey === 'npu' && (
<div
className="m-b-8 text-tertiary"
dangerouslySetInnerHTML={{
__html: intl.formatMessage({ id: 'resources.worker.cann.tips' })
}}
></div>
)}
<HighlightCode theme="dark" code={code}></HighlightCode> <HighlightCode theme="dark" code={code}></HighlightCode>
<h3> <h3>
<BulbOutlined className="m-r-5"></BulbOutlined> <BulbOutlined className="m-r-5"></BulbOutlined>
@@ -12,7 +12,7 @@ const AddWorker: React.FC<ViewModalProps> = (props) => {
const origin = window.location.origin; const origin = window.location.origin;
return ( return (
<div> <div className="script-install">
<h4>{intl.formatMessage({ id: 'resources.worker.linuxormaxos' })}</h4> <h4>{intl.formatMessage({ id: 'resources.worker.linuxormaxos' })}</h4>
<HighlightCode <HighlightCode
code={addWorkerGuide.mac.registerWorker({ code={addWorkerGuide.mac.registerWorker({
@@ -9,5 +9,20 @@
padding-left: 16px; padding-left: 16px;
background: var(--color-fill-sider); background: var(--color-fill-sider);
border-radius: 2px; border-radius: 2px;
list-style-type: decimal;
li {
margin-left: 12px;
}
}
.code-pre {
white-space: pre-wrap;
}
}
.script-install {
.code-pre {
white-space: pre-wrap;
} }
} }
+23 -2
View File
@@ -15,7 +15,7 @@ export const status: any = {
[WorkerStatusMap.not_ready]: StatusMaps.error [WorkerStatusMap.not_ready]: StatusMaps.error
}; };
export const addWorkerGuide = { export const addWorkerGuide: Record<string, any> = {
mac: { mac: {
getToken: 'cat /var/lib/gpustack/token', getToken: 'cat /var/lib/gpustack/token',
registerWorker(params: { server: string; token: string }) { registerWorker(params: { server: string; token: string }) {
@@ -29,12 +29,33 @@ export const addWorkerGuide = {
return `Invoke-Expression "& { $((Invoke-WebRequest -Uri "https://get.gpustack.ai" -UseBasicParsing).Content) } --server-url ${params.server} --token ${params.token}"`; return `Invoke-Expression "& { $((Invoke-WebRequest -Uri "https://get.gpustack.ai" -UseBasicParsing).Content) } --server-url ${params.server} --token ${params.token}"`;
} }
}, },
docker: { cuda: {
getToken: getToken:
'Get-Content -Path (Join-Path -Path $env:APPDATA -ChildPath "gpustack\\token") -Raw', 'Get-Content -Path (Join-Path -Path $env:APPDATA -ChildPath "gpustack\\token") -Raw',
registerWorker(params: { server: string; tag: string; token: string }) { registerWorker(params: { server: string; tag: string; token: string }) {
return `docker run -d --gpus all --ipc=host --network=host gpustack/gpustack:${params.tag} --server-url ${params.server} --token ${params.token}`; return `docker run -d --gpus all --ipc=host --network=host gpustack/gpustack:${params.tag} --server-url ${params.server} --token ${params.token}`;
} }
},
npu: {
getToken:
'Get-Content -Path (Join-Path -Path $env:APPDATA -ChildPath "gpustack\\token") -Raw',
registerWorker(params: { server: string; tag: string; token: string }) {
return `docker run -d --ipc=host -e ASCEND_VISIBLE_DEVICES=0 --network=host gpustack/gpustack:${params.tag} --server-url ${params.server} --token ${params.token}`;
}
},
musa: {
getToken:
'Get-Content -Path (Join-Path -Path $env:APPDATA -ChildPath "gpustack\\token") -Raw',
registerWorker(params: { server: string; tag: string; token: string }) {
return `docker run -d --ipc=host --network=host gpustack/gpustack:${params.tag} --server-url ${params.server} --token ${params.token}`;
}
},
cpu: {
getToken:
'Get-Content -Path (Join-Path -Path $env:APPDATA -ChildPath "gpustack\\token") -Raw',
registerWorker(params: { server: string; tag: string; token: string }) {
return `docker run -d --ipc=host --network=host gpustack/gpustack:${params.tag} --server-url ${params.server} --token ${params.token}`;
}
} }
}; };