From 1d08719645350bb3d45a65b5f93bcf6cb3f7f2d5 Mon Sep 17 00:00:00 2001 From: josc146 Date: Tue, 23 May 2023 12:13:12 +0800 Subject: [PATCH] update requirements and `/status` --- backend-python/requirements.txt | Bin 152 -> 168 bytes backend-python/requirements_versions.txt | Bin 260 -> 290 bytes backend-python/routes/config.py | 16 +++++++++++++--- frontend/src/utils/index.tsx | 6 +++--- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/backend-python/requirements.txt b/backend-python/requirements.txt index c241a89d61f6cd942f0ea8255d42a05a1ac36779..30857abeac802137112736e1e4e4000c34cb6d44 100644 GIT binary patch delta 23 ecmbQixPo!Q41sip0)|qC5{68M90pznE(QQj%>^d_ delta 6 NcmZ3%ID>J*3;+lg0&4&O diff --git a/backend-python/requirements_versions.txt b/backend-python/requirements_versions.txt index 64bf5c534d86a8f9d260a9943dfc5b8d9f4dbaa9..6d94b05d6ed32c8ab2f7e5cdd425334883e6ce34 100644 GIT binary patch delta 38 qcmZo+TEw)0g;6e@p@5;3p@bomA&0>h2n`wZ7)*fJfPt5Riva+c76ugn delta 7 OcmZ3))WWoZg%JP=HUZ!O diff --git a/backend-python/routes/config.py b/backend-python/routes/config.py index 41742ea..8218541 100644 --- a/backend-python/routes/config.py +++ b/backend-python/routes/config.py @@ -6,6 +6,7 @@ from langchain.llms import RWKV from utils.rwkv import * from utils.torch import * import global_var +import GPUtil router = APIRouter() @@ -25,8 +26,8 @@ def switch_model(body: SwitchModelBody, response: Response): global_var.set(global_var.Model_Status, global_var.ModelStatus.Offline) global_var.set(global_var.Model, None) torch_gc() - - os.environ["RWKV_CUDA_ON"] = '1' if body.customCuda else '0' + + os.environ["RWKV_CUDA_ON"] = "1" if body.customCuda else "0" global_var.set(global_var.Model_Status, global_var.ModelStatus.Loading) try: @@ -66,4 +67,13 @@ def update_config(body: ModelConfigBody): @router.get("/status") def status(): - return {"status": global_var.get(global_var.Model_Status)} + gpus = GPUtil.getGPUs() + if len(gpus) == 0: + device_name = "CPU" + else: + device_name = gpus[0].name + return { + "status": global_var.get(global_var.Model_Status), + "pid": os.getpid(), + "device_name": device_name, + } diff --git a/frontend/src/utils/index.tsx b/frontend/src/utils/index.tsx index 4b1629e..c4cca0b 100644 --- a/frontend/src/utils/index.tsx +++ b/frontend/src/utils/index.tsx @@ -189,9 +189,9 @@ export function forceDownloadProgramFiles() { }); } -export function deletePythonProgramFiles() { +export function deleteDynamicProgramFiles() { manifest.programFiles.forEach(({ path }) => { - if (path.endsWith('.py') && !path.includes('get-pip.py')) + if ((path.endsWith('.py') && !path.includes('get-pip.py')) || path.includes('requirements')) DeleteFile(path); }); } @@ -223,7 +223,7 @@ export async function checkUpdate(notifyEvenLatest: boolean = false) { `https://github.com/josStorer/RWKV-Runner/releases/download/${versionTag}/RWKV-Runner_windows_x64.exe` : `https://gitee.com/josc146/RWKV-Runner/releases/download/${versionTag}/RWKV-Runner_windows_x64.exe`; toastWithButton(t('New Version Available') + ': ' + versionTag, t('Update'), () => { - deletePythonProgramFiles(); + deleteDynamicProgramFiles(); setTimeout(() => { UpdateApp(updateUrl).catch((e) => { toast(t('Update Error, Please restart this program') + ' - ' + e.message || e, {