Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Try to improve memory issues with del.

comfyanonymousb31daadc034c
diff --git a/comfy/sd.py b/comfy/sd.py
index 0b55b8b14..4ac11eba1 100644
--- a/comfy/sd.py
+++ b/comfy/sd.py
@@ -222,8 +222,11 @@ class ModelPatcher:
return self.model
def unpatch_model(self):
model_sd = self.model.state_dict()
- for k in self.backup:
+ keys = list(self.backup.keys())
+ for k in keys:
model_sd[k][:] = self.backup[k]
+ del self.backup[k]
+
self.backup = {}
def load_lora_for_models(model, clip, lora_path, strength_model, strength_clip):