From 762ab30c71f394f1dc823cbd70b3bb0a4ea88cf2 Mon Sep 17 00:00:00 2001 From: jialin Date: Mon, 23 Dec 2024 19:11:18 +0800 Subject: [PATCH] chore: add worker command paramters --- src/locales/en-US/resources.ts | 8 ++- src/locales/zh-CN/resources.ts | 8 ++- .../llmodels/components/search-model.tsx | 10 ++-- src/pages/resources/components/add-worker.tsx | 2 +- .../components/container-install.tsx | 52 ++++++++++++++----- .../resources/components/script-install.tsx | 2 +- .../components/styles/installation.less | 15 ++++++ src/pages/resources/config/index.ts | 25 ++++++++- 8 files changed, 94 insertions(+), 28 deletions(-) diff --git a/src/locales/en-US/resources.ts b/src/locales/en-US/resources.ts index 86241591..66e74ada 100644 --- a/src/locales/en-US/resources.ts +++ b/src/locales/en-US/resources.ts @@ -47,10 +47,14 @@ export default { 'Note: mytoken is the token obtained in the first step.', 'resources.worker.add.step3': '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.driver.install': + 'Ensure all necessary drivers and libraries are installed on the system prior to installing GPUStack.', 'resources.worker.select.command': 'Select a label to generate the command and copy it using the copy button.', 'resources.worker.script.install': 'Script Installation', - 'resources.worker.container.install': 'Container Installation' + 'resources.worker.container.install': 'Container Installation', + 'resources.worker.cann.tips': + 'Set ASCEND_VISIBLE_DEVICES to 0 for a single GPU or to the index range (e.g., 0-7 for 8 GPUs) for multiple GPUs.' }; diff --git a/src/locales/zh-CN/resources.ts b/src/locales/zh-CN/resources.ts index eaca6301..61293c82 100644 --- a/src/locales/zh-CN/resources.ts +++ b/src/locales/zh-CN/resources.ts @@ -46,9 +46,13 @@ export default { 'resources.worker.add.step2.tips': '注意:mytoken 为第一步获取到的 Token', 'resources.worker.add.step3': '成功后,刷新 worker 列表即可看到新的 worker', - 'resources.worker.container.supported': '不支持 Windows', + 'resources.worker.container.supported': '不支持 MacOS 和 Windows', 'resources.worker.current.version': '当前版本为 {version}', 'resources.worker.select.command': '选择一个标签生成命令并使用复制按钮复制', + 'resources.worker.driver.install': + '在安装 GPUStack 之前,确保系统上安装了所有必需的驱动程序和库', '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)' }; diff --git a/src/pages/llmodels/components/search-model.tsx b/src/pages/llmodels/components/search-model.tsx index 7d6082ce..45efbedd 100644 --- a/src/pages/llmodels/components/search-model.tsx +++ b/src/pages/llmodels/components/search-model.tsx @@ -1,8 +1,4 @@ -import { - BulbOutlined, - QuestionCircleOutlined, - WarningOutlined -} from '@ant-design/icons'; +import { BulbOutlined, QuestionCircleOutlined } from '@ant-design/icons'; import { useIntl } from '@umijs/max'; import { Checkbox, Select, Tooltip } from 'antd'; import _ from 'lodash'; @@ -238,7 +234,9 @@ const SearchModel: React.FC = (props) => { modelSource={modelSource} >
- + + {intl.formatMessage({ id: 'common.tips.title' })} + {intl.formatMessage({ id: 'models.form.search.gguftips' })} diff --git a/src/pages/resources/components/add-worker.tsx b/src/pages/resources/components/add-worker.tsx index bd1068e8..0c25d7a1 100644 --- a/src/pages/resources/components/add-worker.tsx +++ b/src/pages/resources/components/add-worker.tsx @@ -41,7 +41,7 @@ const AddWorker: React.FC = (props) => { width={600} styles={{ body: { - height: 310 + height: 410 } }} footer={null} diff --git a/src/pages/resources/components/container-install.tsx b/src/pages/resources/components/container-install.tsx index 8f7dae13..1618a37a 100644 --- a/src/pages/resources/components/container-install.tsx +++ b/src/pages/resources/components/container-install.tsx @@ -3,7 +3,7 @@ import { getAtomStorage } from '@/atoms/utils'; import HighlightCode from '@/components/highlight-code'; import { BulbOutlined, WarningOutlined } from '@ant-design/icons'; import { useIntl } from '@umijs/max'; -import { Radio } from 'antd'; +import { Button, Radio } from 'antd'; import React from 'react'; import { addWorkerGuide, containerInstallOptions } from '../config'; import './styles/installation.less'; @@ -24,14 +24,17 @@ const AddWorker: React.FC = (props) => { if (!version || !versionInfo.isProduction) { version = 'main'; } + + const commandCode = addWorkerGuide[activeKey]; + if (activeKey === 'cuda') { - return addWorkerGuide.docker.registerWorker({ + return commandCode?.registerWorker({ server: origin, tag: version, token: props.token }); } - return addWorkerGuide.docker.registerWorker({ + return commandCode?.registerWorker({ server: origin, tag: `${version}-${activeKey}`, token: props.token @@ -40,9 +43,8 @@ const AddWorker: React.FC = (props) => { return (
-
- - 1.{' '} +
    +
  • {intl.formatMessage({ id: 'resources.worker.container.supported' })} @@ -50,18 +52,32 @@ const AddWorker: React.FC = (props) => { style={{ color: 'var(--ant-color-warning)' }} className="font-size-14 m-l-5" /> - - - 2.{' '} +
  • +
  • {intl.formatMessage( { id: 'resources.worker.current.version' }, { version: versionInfo.version } )} - - - 3. {intl.formatMessage({ id: 'resources.worker.select.command' })} - -
+ +
  • {intl.formatMessage({ id: 'resources.worker.select.command' })}
  • +
  • + + {intl.formatMessage({ id: 'resources.worker.driver.install' })} + + + +
  • +
    = (props) => { size="small" />
    + {activeKey === 'npu' && ( +
    + )}

    diff --git a/src/pages/resources/components/script-install.tsx b/src/pages/resources/components/script-install.tsx index 2a59aa93..4e452692 100644 --- a/src/pages/resources/components/script-install.tsx +++ b/src/pages/resources/components/script-install.tsx @@ -12,7 +12,7 @@ const AddWorker: React.FC = (props) => { const origin = window.location.origin; return ( -
    +

    {intl.formatMessage({ id: 'resources.worker.linuxormaxos' })}

    = { mac: { getToken: 'cat /var/lib/gpustack/token', 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}"`; } }, - docker: { + cuda: { 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 --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}`; + } } };