update startup

This commit is contained in:
josc146 2023-10-03 13:50:58 +08:00
parent 68228a4552
commit 71abd357a4
2 changed files with 30 additions and 24 deletions

View File

@ -11,7 +11,7 @@ import { Button } from '@fluentui/react-components';
import { observer } from 'mobx-react-lite'; import { observer } from 'mobx-react-lite';
import { exit, getStatus, readRoot, switchModel, updateConfig } from '../apis'; import { exit, getStatus, readRoot, switchModel, updateConfig } from '../apis';
import { toast } from 'react-toastify'; import { toast } from 'react-toastify';
import { checkDependencies, getStrategy, getSupportedCustomCudaFile, toastWithButton } from '../utils'; import { checkDependencies, getStrategy, toastWithButton } from '../utils';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { ToolTipButton } from './ToolTipButton'; import { ToolTipButton } from './ToolTipButton';
import { Play16Regular, Stop16Regular } from '@fluentui/react-icons'; import { Play16Regular, Stop16Regular } from '@fluentui/react-icons';
@ -119,9 +119,10 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
const startServer = webgpu ? const startServer = webgpu ?
(_: string, port: number, host: string) => StartWebGPUServer(port, host) (_: string, port: number, host: string) => StartWebGPUServer(port, host)
: StartServer; : StartServer;
const isUsingCudaBeta = modelConfig.modelParameters.device === 'CUDA-Beta';
startServer(commonStore.settings.customPythonPath, port, commonStore.settings.host !== '127.0.0.1' ? '0.0.0.0' : '127.0.0.1', startServer(commonStore.settings.customPythonPath, port, commonStore.settings.host !== '127.0.0.1' ? '0.0.0.0' : '127.0.0.1',
modelConfig.modelParameters.device === 'CUDA-Beta' isUsingCudaBeta
).catch((e) => { ).catch((e) => {
const errMsg = e.message || e; const errMsg = e.message || e;
if (errMsg.includes('path contains space')) if (errMsg.includes('path contains space'))
@ -162,22 +163,26 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
if ((modelConfig.modelParameters.device.includes('CUDA') || modelConfig.modelParameters.device === 'Custom') if ((modelConfig.modelParameters.device.includes('CUDA') || modelConfig.modelParameters.device === 'Custom')
&& modelConfig.modelParameters.useCustomCuda && !strategy.includes('fp32')) { && modelConfig.modelParameters.useCustomCuda && !strategy.includes('fp32')) {
if (commonStore.platform === 'windows') { if (commonStore.platform === 'windows') {
customCudaFile = getSupportedCustomCudaFile(); // this part is currently unused because there's no longer a need to use different kernels for different GPUs, but it might still be needed in the future
if (customCudaFile) { //
FileExists('./py310/Lib/site-packages/rwkv/model.py').then((exist) => { // customCudaFile = getSupportedCustomCudaFile(isUsingCudaBeta);
// defensive measure. As Python has already been launched, will only take effect the next time it runs. // if (customCudaFile) {
if (!exist) CopyFile('./backend-python/wkv_cuda_utils/wkv_cuda_model.py', './py310/Lib/site-packages/rwkv/model.py'); // let kernelTargetPath: string;
}); // if (isUsingCudaBeta)
await CopyFile(customCudaFile, './py310/Lib/site-packages/rwkv/wkv_cuda.pyd').catch(() => { // kernelTargetPath = './backend-python/rwkv_pip/beta/wkv_cuda.pyd';
FileExists('./py310/Lib/site-packages/rwkv/wkv_cuda.pyd').then((exist) => { // else
if (!exist) { // kernelTargetPath = './backend-python/rwkv_pip/wkv_cuda.pyd';
customCudaFile = ''; // await CopyFile(customCudaFile, kernelTargetPath).catch(() => {
toast(t('Failed to copy custom cuda file'), { type: 'error' }); // FileExists(kernelTargetPath).then((exist) => {
} // if (!exist) {
}); // customCudaFile = '';
}); // toast(t('Failed to copy custom cuda file'), { type: 'error' });
} else // }
toast(t('Supported custom cuda file not found'), { type: 'warning' }); // });
// });
// } else
// toast(t('Supported custom cuda file not found'), { type: 'warning' });
customCudaFile = 'any';
} else { } else {
customCudaFile = 'any'; customCudaFile = 'any';
} }

View File

@ -1,6 +1,5 @@
import { import {
AddToDownloadList, AddToDownloadList,
CopyFile,
DeleteFile, DeleteFile,
DepCheck, DepCheck,
InstallPyDep, InstallPyDep,
@ -402,8 +401,6 @@ export const checkDependencies = async (navigate: NavigateFunction) => {
return false; return false;
} }
commonStore.setDepComplete(true); commonStore.setDepComplete(true);
if (commonStore.platform === 'windows')
CopyFile('./backend-python/wkv_cuda_utils/wkv_cuda_model.py', './py310/Lib/site-packages/rwkv/model.py');
} }
return true; return true;
}; };
@ -428,12 +425,16 @@ export function toastWithButton(text: string, buttonText: string, onClickButton:
return id; return id;
} }
export function getSupportedCustomCudaFile() { export function getSupportedCustomCudaFile(isBeta: boolean) {
if ([' 10', ' 16', ' 20', ' 30', 'MX', 'Tesla P', 'Quadro P', 'NVIDIA P', 'TITAN X', 'TITAN RTX', 'RTX A', if ([' 10', ' 16', ' 20', ' 30', 'MX', 'Tesla P', 'Quadro P', 'NVIDIA P', 'TITAN X', 'TITAN RTX', 'RTX A',
'Quadro RTX 4000', 'Quadro RTX 5000', 'Tesla T4', 'NVIDIA A10', 'NVIDIA A40'].some(v => commonStore.status.device_name.includes(v))) 'Quadro RTX 4000', 'Quadro RTX 5000', 'Tesla T4', 'NVIDIA A10', 'NVIDIA A40'].some(v => commonStore.status.device_name.includes(v)))
return './backend-python/wkv_cuda_utils/wkv_cuda10_30.pyd'; return isBeta ?
'./backend-python/wkv_cuda_utils/beta/wkv_cuda10_30.pyd' :
'./backend-python/wkv_cuda_utils/wkv_cuda10_30.pyd';
else if ([' 40', 'RTX 5000 Ada', 'RTX 6000 Ada', 'RTX TITAN Ada', 'NVIDIA L40'].some(v => commonStore.status.device_name.includes(v))) else if ([' 40', 'RTX 5000 Ada', 'RTX 6000 Ada', 'RTX TITAN Ada', 'NVIDIA L40'].some(v => commonStore.status.device_name.includes(v)))
return './backend-python/wkv_cuda_utils/wkv_cuda40.pyd'; return isBeta ?
'./backend-python/wkv_cuda_utils/beta/wkv_cuda40.pyd' :
'./backend-python/wkv_cuda_utils/wkv_cuda40.pyd';
else else
return ''; return '';
} }