From 5f26b76f5994ff80e6e0fd66fac7e0bc92edc863 Mon Sep 17 00:00:00 2001 From: doctorpangloss <@hiddenswitch.com> Date: Thu, 10 Oct 2024 10:42:22 -0700 Subject: [PATCH] Gracefully handle running with cuda torch on CPU only devices --- comfy/model_management.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/comfy/model_management.py b/comfy/model_management.py index a9468a5ba..cb3917757 100644 --- a/comfy/model_management.py +++ b/comfy/model_management.py @@ -1225,6 +1225,9 @@ def should_use_bf16(device=None, model_params=0, prioritize_performance=True, ma props_major = min(torch.cuda.get_device_properties(torch.device(f"cuda:{i}")).major for i in range(torch.cuda.device_count())) if props_major >= 8: return True + except ValueError: + logging.warning("No CUDA devices were present, even though CUDA is available in this torch installation. This assumes the CPU device will be selected for computation") + return False except AssertionError: logging.warning("Torch was not compiled with CUDA support") return False