From 42ca30d6c1b7dff737f49ca20409281947b0b110 Mon Sep 17 00:00:00 2001 From: AUTOMATIC1111 <16777216c@gmail.com> Date: Thu, 27 Jun 2024 07:35:53 +0300 Subject: [PATCH] fix mdevram for SD1/SDXL --- modules/lowvram.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/lowvram.py b/modules/lowvram.py index 00aad477b..6728c337b 100644 --- a/modules/lowvram.py +++ b/modules/lowvram.py @@ -107,7 +107,7 @@ def setup_for_low_vram(sd_model, use_medvram): setattr(obj, field, module) # register hooks for those the first three models - if hasattr(sd_model.cond_stage_model, "medvram_modules"): + if hasattr(sd_model, "cond_stage_model") and hasattr(sd_model.cond_stage_model, "medvram_modules"): for module in sd_model.cond_stage_model.medvram_modules(): if isinstance(module, ModuleWithParent): parent = module.parent @@ -135,9 +135,9 @@ def setup_for_low_vram(sd_model, use_medvram): 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 hasattr(sd_model, 'depth_model'): + if getattr(sd_model, 'depth_model', None) is not None: sd_model.depth_model.register_forward_pre_hook(send_me_to_gpu) - if hasattr(sd_model, 'embedder'): + if getattr(sd_model, 'embedder', None) is not None: sd_model.embedder.register_forward_pre_hook(send_me_to_gpu) if use_medvram: