From 8283774b86e51caa529de3e16601021fc2a654e7 Mon Sep 17 00:00:00 2001 From: lllyasviel Date: Thu, 22 Feb 2024 10:24:27 -0800 Subject: [PATCH] revise caster --- ldm_patched/modules/model_management.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ldm_patched/modules/model_management.py b/ldm_patched/modules/model_management.py index c1447cc9..9a0f2a37 100644 --- a/ldm_patched/modules/model_management.py +++ b/ldm_patched/modules/model_management.py @@ -317,6 +317,8 @@ class LoadedModel: if mem_counter + module_mem < lowvram_model_memory: m.to(self.device) mem_counter += module_mem + else: + m._apply(lambda x: x.pin_memory()) elif hasattr(m, "weight"): #only modules with ldm_patched_cast_weights can be set to lowvram mode m.to(self.device) mem_counter += module_size(m)