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.

Fix on-load VRAM OOM (#11144)

rattus4086acf3c2f0
diff --git a/comfy/model_patcher.py b/comfy/model_patcher.py
index 4f076a6aa..5b1ccb824 100644
--- a/comfy/model_patcher.py
+++ b/comfy/model_patcher.py
@@ -762,6 +762,8 @@ class ModelPatcher:
key = "{}.{}".format(n, param)
self.unpin_weight(key)
self.patch_weight_to_device(key, device_to=device_to)
+ if comfy.model_management.is_device_cuda(device_to):
+ torch.cuda.synchronize()
logging.debug("lowvram: loaded module regularly {} {}".format(n, m))
m.comfy_patched_weights = True