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.

model_mangament: make dynamic --disable-smart-memory work (#12724)

rattusdfbf99a06172
diff --git a/comfy/cli_args.py b/comfy/cli_args.py
index bfb61c825..13079c7bc 100644
--- a/comfy/cli_args.py
+++ b/comfy/cli_args.py
@@ -260,4 +260,4 @@ else:
args.fast = set(args.fast)
def enables_dynamic_vram():
- return not args.disable_dynamic_vram and not args.highvram and not args.gpu_only and not args.novram and not args.cpu and not args.disable_smart_memory
+ return not args.disable_dynamic_vram and not args.highvram and not args.gpu_only and not args.novram and not args.cpu
diff --git a/comfy/model_management.py b/comfy/model_management.py
index 86f840ada..c817d43b5 100644
--- a/comfy/model_management.py
+++ b/comfy/model_management.py
@@ -639,12 +639,11 @@ def free_memory(memory_required, device, keep_loaded=[], for_dynamic=False, ram_
if not DISABLE_SMART_MEMORY:
memory_to_free = memory_required - get_free_memory(device)
ram_to_free = ram_required - get_free_ram()
-
- if current_loaded_models[i].model.is_dynamic() and for_dynamic:
- #don't actually unload dynamic models for the sake of other dynamic models
- #as that works on-demand.
- memory_required -= current_loaded_models[i].model.loaded_size()
- memory_to_free = 0
+ if current_loaded_models[i].model.is_dynamic() and for_dynamic:
+ #don't actually unload dynamic models for the sake of other dynamic models
+ #as that works on-demand.
+ memory_required -= current_loaded_models[i].model.loaded_size()
+ memory_to_free = 0
if memory_to_free > 0 and current_loaded_models[i].model_unload(memory_to_free):
logging.debug(f"Unloading {current_loaded_models[i].model.model.__class__.__name__}")
unloaded_model.append(i)