From 06b41aee582b259e7ad4bef738d0aa7840ee8872 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 16 Nov 2022 19:29:04 +0530 Subject: [PATCH] Fix - reduce the amount of VRAM occupied when the program starts up, this caused a regression and failures on GPUs with 4 gb or less of VRAM --- ui/index.html | 2 +- ui/sd_internal/runtime.py | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ui/index.html b/ui/index.html index 2e817256..0ade5069 100644 --- a/ui/index.html +++ b/ui/index.html @@ -19,7 +19,7 @@
diff --git a/ui/sd_internal/runtime.py b/ui/sd_internal/runtime.py index 1d77ad51..e2346730 100644 --- a/ui/sd_internal/runtime.py +++ b/ui/sd_internal/runtime.py @@ -118,8 +118,8 @@ def load_model_ckpt(): model.cdevice = torch.device(thread_data.device) model.unet_bs = thread_data.unet_bs model.turbo = thread_data.turbo - if thread_data.device != 'cpu': - model.to(thread_data.device) + # if thread_data.device != 'cpu': + # model.to(thread_data.device) #if thread_data.reduced_memory: #model.model1.to("cpu") #model.model2.to("cpu") @@ -129,11 +129,11 @@ def load_model_ckpt(): _, _ = modelCS.load_state_dict(sd, strict=False) modelCS.eval() modelCS.cond_stage_model.device = torch.device(thread_data.device) - if thread_data.device != 'cpu': - if thread_data.reduced_memory: - modelCS.to('cpu') - else: - modelCS.to(thread_data.device) # Preload on device if not already there. + # if thread_data.device != 'cpu': + # if thread_data.reduced_memory: + # modelCS.to('cpu') + # else: + # modelCS.to(thread_data.device) # Preload on device if not already there. thread_data.modelCS = modelCS modelFS = instantiate_from_config(config.modelFirstStage) @@ -151,11 +151,11 @@ def load_model_ckpt(): print(f'Cannot find VAE file: {thread_data.vae_file}{model_extension}') modelFS.eval() - if thread_data.device != 'cpu': - if thread_data.reduced_memory: - modelFS.to('cpu') - else: - modelFS.to(thread_data.device) # Preload on device if not already there. + # if thread_data.device != 'cpu': + # if thread_data.reduced_memory: + # modelFS.to('cpu') + # else: + # modelFS.to(thread_data.device) # Preload on device if not already there. thread_data.modelFS = modelFS del sd