diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-07-08 14:13:18 +0000 |
---|---|---|
committer | AUTOMATIC1111 <16777216c@gmail.com> | 2023-07-08 14:13:18 +0000 |
commit | da8916f92649fc4d947cb46d9d8f8ea1621b2a59 (patch) | |
tree | b3c6883f8c731b0e1291e61a16f16b12ed22e101 /modules/devices.py | |
parent | e161b5a0259c870b9d01408d02c504c3281dbdb1 (diff) | |
download | stable-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.py | 3 |
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(): |