diff options
author | Jairo Correa <jn.j41r0@gmail.com> | 2022-09-29 01:14:13 +0000 |
---|---|---|
committer | Jairo Correa <jn.j41r0@gmail.com> | 2022-09-29 01:14:13 +0000 |
commit | c938679de7b87b4f14894d9f57fe0f40dd6e3c06 (patch) | |
tree | 31119c9dc5d04648bf873069c690b4fd53dc3805 /modules/devices.py | |
parent | 041d2aefc082c2883aa7e28ee3e4a990b3be9758 (diff) | |
download | stable-diffusion-webui-gfx803-c938679de7b87b4f14894d9f57fe0f40dd6e3c06.tar.gz stable-diffusion-webui-gfx803-c938679de7b87b4f14894d9f57fe0f40dd6e3c06.tar.bz2 stable-diffusion-webui-gfx803-c938679de7b87b4f14894d9f57fe0f40dd6e3c06.zip |
Fix memory leak and reduce memory usage
Diffstat (limited to 'modules/devices.py')
-rw-r--r-- | modules/devices.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/modules/devices.py b/modules/devices.py index 07bb2339..df63dd88 100644 --- a/modules/devices.py +++ b/modules/devices.py @@ -1,4 +1,5 @@ import torch +import gc # has_mps is only available in nightly pytorch (for now), `getattr` for compatibility from modules import errors @@ -17,8 +18,8 @@ def get_optimal_device(): return cpu - def torch_gc(): + gc.collect() if torch.cuda.is_available(): torch.cuda.empty_cache() torch.cuda.ipc_collect() |