diff options
author | yfszzx <yfszzx@gmail.com> | 2022-10-23 08:17:37 +0000 |
---|---|---|
committer | yfszzx <yfszzx@gmail.com> | 2022-10-23 08:17:37 +0000 |
commit | 6a9ea40d7f64139f23d634efd7c2fb2c743a546f (patch) | |
tree | 8d420a5590c09e1d4c005a709166479856e70580 /modules/lowvram.py | |
parent | 67b78f0ea6f196bfdca49932da062631bb40d0b1 (diff) | |
parent | 1ef32c8b8fa3e16a1e7b287eb19d4fc943d1f2a5 (diff) | |
download | stable-diffusion-webui-gfx803-6a9ea40d7f64139f23d634efd7c2fb2c743a546f.tar.gz stable-diffusion-webui-gfx803-6a9ea40d7f64139f23d634efd7c2fb2c743a546f.tar.bz2 stable-diffusion-webui-gfx803-6a9ea40d7f64139f23d634efd7c2fb2c743a546f.zip |
Move browser and Inspiration into extension
Diffstat (limited to 'modules/lowvram.py')
-rw-r--r-- | modules/lowvram.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/modules/lowvram.py b/modules/lowvram.py index 7eba1349..f327c3df 100644 --- a/modules/lowvram.py +++ b/modules/lowvram.py @@ -1,9 +1,8 @@ import torch
-from modules.devices import get_optimal_device
+from modules import devices
module_in_gpu = None
cpu = torch.device("cpu")
-device = gpu = get_optimal_device()
def send_everything_to_cpu():
@@ -33,7 +32,7 @@ def setup_for_low_vram(sd_model, use_medvram): if module_in_gpu is not None:
module_in_gpu.to(cpu)
- module.to(gpu)
+ module.to(devices.device)
module_in_gpu = module
# see below for register_forward_pre_hook;
@@ -51,7 +50,7 @@ def setup_for_low_vram(sd_model, use_medvram): # 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
- sd_model.to(device)
+ sd_model.to(devices.device)
sd_model.cond_stage_model.transformer, sd_model.first_stage_model, sd_model.model = stored
# register hooks for those the first two models
@@ -70,7 +69,7 @@ def setup_for_low_vram(sd_model, use_medvram): # so that only one of them is in GPU at a time
stored = diff_model.input_blocks, diff_model.middle_block, diff_model.output_blocks, diff_model.time_embed
diff_model.input_blocks, diff_model.middle_block, diff_model.output_blocks, diff_model.time_embed = None, None, None, None
- sd_model.model.to(device)
+ sd_model.model.to(devices.device)
diff_model.input_blocks, diff_model.middle_block, diff_model.output_blocks, diff_model.time_embed = stored
# install hooks for bits of third model
|