From d6731f4adf1a70a6610635ed017c9f85555c8b2a Mon Sep 17 00:00:00 2001 From: wataru Date: Mon, 5 Jun 2023 02:02:48 +0900 Subject: [PATCH] strict cuda check --- server/voice_changer/RVC/deviceManager/DeviceManager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/voice_changer/RVC/deviceManager/DeviceManager.py b/server/voice_changer/RVC/deviceManager/DeviceManager.py index 50bfab7e..cf28bcd8 100644 --- a/server/voice_changer/RVC/deviceManager/DeviceManager.py +++ b/server/voice_changer/RVC/deviceManager/DeviceManager.py @@ -30,7 +30,8 @@ class DeviceManager(object): def getOnnxExecutionProvider(self, gpu: int): availableProviders = onnxruntime.get_available_providers() - if gpu >= 0 and "CUDAExecutionProvider" in availableProviders: + devNum = torch.cuda.device_count() + if gpu >= 0 and "CUDAExecutionProvider" in availableProviders and devNum > 0: return ["CUDAExecutionProvider"], [{"device_id": gpu}] elif gpu >= 0 and "DmlExecutionProvider" in availableProviders: return ["DmlExecutionProvider"], [{}]