aboutsummaryrefslogtreecommitdiffstats
path: root/modules/devices.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-07-08 14:13:18 +0000
committerAUTOMATIC1111 <16777216c@gmail.com>2023-07-08 14:13:18 +0000
commitda8916f92649fc4d947cb46d9d8f8ea1621b2a59 (patch)
treeb3c6883f8c731b0e1291e61a16f16b12ed22e101 /modules/devices.py
parente161b5a0259c870b9d01408d02c504c3281dbdb1 (diff)
downloadstable-diffusion-webui-gfx803-da8916f92649fc4d947cb46d9d8f8ea1621b2a59.tar.gz
stable-diffusion-webui-gfx803-da8916f92649fc4d947cb46d9d8f8ea1621b2a59.tar.bz2
stable-diffusion-webui-gfx803-da8916f92649fc4d947cb46d9d8f8ea1621b2a59.zip
added torch.mps.empty_cache() to torch_gc()
changed a bunch of places that use torch.cuda.empty_cache() to use torch_gc() instead
Diffstat (limited to 'modules/devices.py')
-rw-r--r--modules/devices.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/modules/devices.py b/modules/devices.py
index 620ed1a6..c5ad950f 100644
--- a/modules/devices.py
+++ b/modules/devices.py
@@ -49,10 +49,13 @@ def get_device_for(task):
def torch_gc():
+
if torch.cuda.is_available():
with torch.cuda.device(get_cuda_device_string()):
torch.cuda.empty_cache()
torch.cuda.ipc_collect()
+ elif has_mps() and hasattr(torch.mps, 'empty_cache'):
+ torch.mps.empty_cache()
def enable_tf32():