aboutsummaryrefslogtreecommitdiffstats
path: root/modules/devices.py
diff options
context:
space:
mode:
authorCodeHatchling <steve@codehatch.com>2023-12-05 03:38:13 +0000
committerCodeHatchling <steve@codehatch.com>2023-12-05 03:38:13 +0000
commit38864816fa8c83d079a49f94674ca3dede9dcaad (patch)
treedfd1b97ad7c5c66ffc5c8641c6e7cc635441e82b /modules/devices.py
parent49bbf1140731036875573bb7c44aa7e74623c856 (diff)
parent22e23dbf29b0bbc807daa57318c31145f8dd0774 (diff)
downloadstable-diffusion-webui-gfx803-38864816fa8c83d079a49f94674ca3dede9dcaad.tar.gz
stable-diffusion-webui-gfx803-38864816fa8c83d079a49f94674ca3dede9dcaad.tar.bz2
stable-diffusion-webui-gfx803-38864816fa8c83d079a49f94674ca3dede9dcaad.zip
Merge remote-tracking branch 'origin2/dev' into soft-inpainting
# Conflicts: # modules/processing.py
Diffstat (limited to 'modules/devices.py')
-rw-r--r--modules/devices.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/modules/devices.py b/modules/devices.py
index 1d4eb563..ea1f712f 100644
--- a/modules/devices.py
+++ b/modules/devices.py
@@ -8,6 +8,13 @@ from modules import errors, shared
if sys.platform == "darwin":
from modules import mac_specific
+if shared.cmd_opts.use_ipex:
+ from modules import xpu_specific
+
+
+def has_xpu() -> bool:
+ return shared.cmd_opts.use_ipex and xpu_specific.has_xpu
+
def has_mps() -> bool:
if sys.platform != "darwin":
@@ -30,6 +37,9 @@ def get_optimal_device_name():
if has_mps():
return "mps"
+ if has_xpu():
+ return xpu_specific.get_xpu_device_string()
+
return "cpu"
@@ -38,7 +48,7 @@ def get_optimal_device():
def get_device_for(task):
- if task in shared.cmd_opts.use_cpu:
+ if task in shared.cmd_opts.use_cpu or "all" in shared.cmd_opts.use_cpu:
return cpu
return get_optimal_device()
@@ -54,6 +64,9 @@ def torch_gc():
if has_mps():
mac_specific.torch_mps_gc()
+ if has_xpu():
+ xpu_specific.torch_xpu_gc()
+
def enable_tf32():
if torch.cuda.is_available():