aboutsummaryrefslogtreecommitdiffstats
path: root/modules/lowvram.py
diff options
context:
space:
mode:
authorBilly Cao <aliencaocao@gmail.com>2022-11-27 04:39:31 +0000
committerGitHub <noreply@github.com>2022-11-27 04:39:31 +0000
commit349f0461ecd5f2522179e644213e2c65da34fc7c (patch)
treef71359be2e68f7dc311b0126d0af669a29f92a81 /modules/lowvram.py
parentadb6cb7619989cbc7a271cc6c2ae27bb936c43d9 (diff)
parentb5050ad2071644f7b4c99660dc66a8a95136102f (diff)
downloadstable-diffusion-webui-gfx803-349f0461ecd5f2522179e644213e2c65da34fc7c.tar.gz
stable-diffusion-webui-gfx803-349f0461ecd5f2522179e644213e2c65da34fc7c.tar.bz2
stable-diffusion-webui-gfx803-349f0461ecd5f2522179e644213e2c65da34fc7c.zip
Merge branch 'master' into support_any_resolution
Diffstat (limited to 'modules/lowvram.py')
-rw-r--r--modules/lowvram.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/lowvram.py b/modules/lowvram.py
index a4652cb1..aa464a95 100644
--- a/modules/lowvram.py
+++ b/modules/lowvram.py
@@ -51,6 +51,10 @@ def setup_for_low_vram(sd_model, use_medvram):
send_me_to_gpu(first_stage_model, None)
return first_stage_model_decode(z)
+ # for SD1, cond_stage_model is CLIP and its NN is in the tranformer frield, but for SD2, it's open clip, and it's in model field
+ if hasattr(sd_model.cond_stage_model, 'model'):
+ sd_model.cond_stage_model.transformer = sd_model.cond_stage_model.model
+
# remove three big modules, cond, first_stage, and unet from the model and then
# send the model to GPU. Then put modules back. the modules will be in CPU.
stored = sd_model.cond_stage_model.transformer, sd_model.first_stage_model, sd_model.model
@@ -65,6 +69,10 @@ def setup_for_low_vram(sd_model, use_medvram):
sd_model.first_stage_model.decode = first_stage_model_decode_wrap
parents[sd_model.cond_stage_model.transformer] = sd_model.cond_stage_model
+ if hasattr(sd_model.cond_stage_model, 'model'):
+ sd_model.cond_stage_model.model = sd_model.cond_stage_model.transformer
+ del sd_model.cond_stage_model.transformer
+
if use_medvram:
sd_model.model.register_forward_pre_hook(send_me_to_gpu)
else: