diff options
author | MrCheeze <fishycheeze@yahoo.ca> | 2022-12-10 16:02:47 +0000 |
---|---|---|
committer | MrCheeze <fishycheeze@yahoo.ca> | 2022-12-10 16:02:47 +0000 |
commit | a1c8ad88283f7b3e861e4722c71e39bf71eec744 (patch) | |
tree | 681918fbe83e73800a8477a2087d457fe8d0960f /modules | |
parent | 685f9631b56ff8bd43bce24ff5ce0f9a0e9af490 (diff) | |
download | stable-diffusion-webui-gfx803-a1c8ad88283f7b3e861e4722c71e39bf71eec744.tar.gz stable-diffusion-webui-gfx803-a1c8ad88283f7b3e861e4722c71e39bf71eec744.tar.bz2 stable-diffusion-webui-gfx803-a1c8ad88283f7b3e861e4722c71e39bf71eec744.zip |
unload depth model if medvram/lowvram enabled
Diffstat (limited to 'modules')
-rw-r--r-- | modules/lowvram.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/modules/lowvram.py b/modules/lowvram.py index aa464a95..042a0254 100644 --- a/modules/lowvram.py +++ b/modules/lowvram.py @@ -55,18 +55,20 @@ def setup_for_low_vram(sd_model, use_medvram): 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
+ # remove four big modules, cond, first_stage, depth (if applicable), 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
- sd_model.cond_stage_model.transformer, sd_model.first_stage_model, sd_model.model = None, None, None
+ stored = sd_model.cond_stage_model.transformer, sd_model.first_stage_model, getattr(sd_model, 'depth_model', None), sd_model.model
+ sd_model.cond_stage_model.transformer, sd_model.first_stage_model, sd_model.depth_model, sd_model.model = None, None, None, None
sd_model.to(devices.device)
- sd_model.cond_stage_model.transformer, sd_model.first_stage_model, sd_model.model = stored
+ sd_model.cond_stage_model.transformer, sd_model.first_stage_model, sd_model.depth_model, sd_model.model = stored
- # register hooks for those the first two models
+ # register hooks for those the first three models
sd_model.cond_stage_model.transformer.register_forward_pre_hook(send_me_to_gpu)
sd_model.first_stage_model.register_forward_pre_hook(send_me_to_gpu)
sd_model.first_stage_model.encode = first_stage_model_encode_wrap
sd_model.first_stage_model.decode = first_stage_model_decode_wrap
+ if sd_model.depth_model:
+ sd_model.depth_model.register_forward_pre_hook(send_me_to_gpu)
parents[sd_model.cond_stage_model.transformer] = sd_model.cond_stage_model
if hasattr(sd_model.cond_stage_model, 'model'):
|