diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-08-28 12:03:46 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-28 12:03:46 +0000 |
commit | 9e14cac3182b53173f1c356f2f13bd1cb0cedc89 (patch) | |
tree | 12b4e04a8f17c4275c26bc23870cab0535e053e0 /modules/lowvram.py | |
parent | f898833ea38718e87b39ab090b2a2325638559cb (diff) | |
parent | 8632452627e1341bcd447dbec3c1516f319200a0 (diff) | |
download | stable-diffusion-webui-gfx803-9e14cac3182b53173f1c356f2f13bd1cb0cedc89.tar.gz stable-diffusion-webui-gfx803-9e14cac3182b53173f1c356f2f13bd1cb0cedc89.tar.bz2 stable-diffusion-webui-gfx803-9e14cac3182b53173f1c356f2f13bd1cb0cedc89.zip |
Merge branch 'dev' into patch-1
Diffstat (limited to 'modules/lowvram.py')
-rw-r--r-- | modules/lowvram.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/modules/lowvram.py b/modules/lowvram.py index 3f830664..45701046 100644 --- a/modules/lowvram.py +++ b/modules/lowvram.py @@ -1,5 +1,5 @@ import torch
-from modules import devices
+from modules import devices, shared
module_in_gpu = None
cpu = torch.device("cpu")
@@ -14,7 +14,24 @@ def send_everything_to_cpu(): module_in_gpu = None
+def is_needed(sd_model):
+ return shared.cmd_opts.lowvram or shared.cmd_opts.medvram or shared.cmd_opts.medvram_sdxl and hasattr(sd_model, 'conditioner')
+
+
+def apply(sd_model):
+ enable = is_needed(sd_model)
+ shared.parallel_processing_allowed = not enable
+
+ if enable:
+ setup_for_low_vram(sd_model, not shared.cmd_opts.lowvram)
+ else:
+ sd_model.lowvram = False
+
+
def setup_for_low_vram(sd_model, use_medvram):
+ if getattr(sd_model, 'lowvram', False):
+ return
+
sd_model.lowvram = True
parents = {}
@@ -127,4 +144,4 @@ def setup_for_low_vram(sd_model, use_medvram): def is_enabled(sd_model):
- return getattr(sd_model, 'lowvram', False)
+ return sd_model.lowvram
|