From 7d38b13a390c40f5bc7f7bcd75c6638e808a85e5 Mon Sep 17 00:00:00 2001 From: misyaguziya <53165965+misyaguziya@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:57:29 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8D=EF=B8=8F[Update]=20Controller=20:?= =?UTF-8?q?=20CUDA=E3=81=8C=E4=BD=BF=E7=94=A8=E3=81=A7=E3=81=8D=E3=81=AA?= =?UTF-8?q?=E3=81=84=E5=A0=B4=E5=90=88=E3=81=AB=E3=83=87=E3=83=90=E3=82=A4?= =?UTF-8?q?=E3=82=B9=E8=A8=AD=E5=AE=9A=E3=82=92cuda=E3=81=8B=E3=82=89cpu?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4=E3=81=99=E3=82=8B=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-python/webui_controller.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src-python/webui_controller.py b/src-python/webui_controller.py index 371dda1b..6e8cae8f 100644 --- a/src-python/webui_controller.py +++ b/src-python/webui_controller.py @@ -398,10 +398,6 @@ class Controller: def getTransparencyRange(*args, **kwargs) -> dict: return {"status":200, "result":config.TRANSPARENCY_RANGE} - @staticmethod - def getAppearanceThemesList(*args, **kwargs) -> dict: - return {"status":200, "result":config.APPEARANCE_THEME_LIST} - @staticmethod def getUiScalingRange(*args, **kwargs) -> dict: return {"status":200, "result":config.UI_SCALING_RANGE} @@ -416,8 +412,11 @@ class Controller: @staticmethod def getComputeDeviceList(*args, **kwargs) -> dict: - device_list = [{"type":"cuda", "device_index": i, "name": torch.cuda.get_device_name(i)} for i in range(torch.cuda.device_count())] - device_list.append({"type":"cpu", "device_index": 0, "name": "cpu"}) + device_list = [] + if torch.cuda.is_available(): + for i in range(torch.cuda.device_count()): + device_list.append({"device":"cuda", "device_index": i, "name": torch.cuda.get_device_name(i)}) + device_list.append({"device":"cpu", "device_index": 0, "name": "cpu"}) return {"status":200, "result":device_list} @staticmethod @@ -615,15 +614,6 @@ class Controller: config.TRANSPARENCY = int(data) return {"status":200, "result":config.TRANSPARENCY} - @staticmethod - def getAppearanceTheme(*args, **kwargs) -> dict: - return {"status":200, "result":config.APPEARANCE_THEME} - - @staticmethod - def setAppearanceTheme(data, *args, **kwargs) -> dict: - config.APPEARANCE_THEME = data - return {"status":200, "result":config.APPEARANCE_THEME} - @staticmethod def getUiScaling(*args, **kwargs) -> dict: return {"status":200, "result":config.UI_SCALING} @@ -1639,6 +1629,14 @@ class Controller: th_download.daemon = True th_download.start() + @staticmethod + def updateComputeDeviceSettings() -> None: + if torch.cuda.is_available() is False: + if config.SELECTED_TRANSLATION_COMPUTE_DEVICE["device"] != "cpu": + config.SELECTED_TRANSLATION_COMPUTE_DEVICE = {"device":"cpu", "device_id":0, "device_name":"cpu"} + if config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["device"] != "cpu": + config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE = {"device":"cpu", "device_id":0, "device_name":"cpu"} + @staticmethod def startWatchdog(*args, **kwargs) -> dict: model.startWatchdog() @@ -1689,6 +1687,10 @@ class Controller: self.updateDownloadedWhisperModelWeight() self.updateTranscriptionEngine() + # set Compute CPU or CUDA + printLog("Set Compute CPU or CUDA") + self.updateComputeDeviceSettings() + # set word filter printLog("Set Word Filter") model.addKeywords()