From 0fd706f3929df0d9d70b9ee2a7f3dc27c8c66827 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Fri, 10 Mar 2023 10:19:55 +0530 Subject: [PATCH] Bring back the ability to run on CPU on PCs with CUDA-compatible GPUs --- ui/easydiffusion/device_manager.py | 12 +++++++----- ui/easydiffusion/task_manager.py | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ui/easydiffusion/device_manager.py b/ui/easydiffusion/device_manager.py index d47807f3..18069a82 100644 --- a/ui/easydiffusion/device_manager.py +++ b/ui/easydiffusion/device_manager.py @@ -65,10 +65,12 @@ def get_device_delta(render_devices, active_devices): def is_mps_available(): - return platform.system() == "Darwin" and \ - hasattr(torch.backends, 'mps') and \ - torch.backends.mps.is_available() and \ - torch.backends.mps.is_built() + return ( + platform.system() == "Darwin" + and hasattr(torch.backends, "mps") + and torch.backends.mps.is_available() + and torch.backends.mps.is_built() + ) def is_cuda_available(): @@ -213,7 +215,7 @@ def is_device_compatible(device): log.error(str(e)) return False - if not is_cuda_available(): + if device in ("cpu", "mps"): return True # Memory check try: diff --git a/ui/easydiffusion/task_manager.py b/ui/easydiffusion/task_manager.py index 80c60323..31fdaa6f 100644 --- a/ui/easydiffusion/task_manager.py +++ b/ui/easydiffusion/task_manager.py @@ -385,7 +385,7 @@ def get_devices(): } def get_device_info(device): - if not device_manager.is_cuda_available(): + if device in ("cpu", "mps"): return {"name": device_manager.get_processor_name()} mem_free, mem_total = torch.cuda.mem_get_info(device)