Skip to content

Commit 855849c

Browse files
authored
mm: Remove Aimdo exemption for empty_cache (Comfy-Org#12260)
Its more important to get the torch caching allocator GC up and running than supporting the pyt2.7 bug. Switch it on. Defeature dynamic_vram + pyt2.7.
1 parent fe25114 commit 855849c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

comfy/model_management.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,11 +1724,9 @@ def soft_empty_cache(force=False):
17241724
elif is_mlu():
17251725
torch.mlu.empty_cache()
17261726
elif torch.cuda.is_available():
1727-
if comfy.memory_management.aimdo_allocator is None:
1728-
#Pytorch 2.7 and earlier crashes if you try and empty_cache when mempools exist
1729-
torch.cuda.synchronize()
1730-
torch.cuda.empty_cache()
1731-
torch.cuda.ipc_collect()
1727+
torch.cuda.synchronize()
1728+
torch.cuda.empty_cache()
1729+
torch.cuda.ipc_collect()
17321730

17331731
def unload_all_models():
17341732
free_memory(1e30, get_torch_device())

main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,10 @@ def execute_script(script_path):
192192
import comfy_aimdo.torch
193193

194194
if enables_dynamic_vram():
195-
if comfy_aimdo.control.init_device(comfy.model_management.get_torch_device().index):
195+
if comfy.model_management.torch_version_numeric < (2, 8):
196+
logging.warning("Unsupported Pytorch detected. DynamicVRAM support requires Pytorch version 2.8 or later. Falling back to legacy ModelPatcher. VRAM estimates may be unreliable especially on Windows")
197+
comfy.memory_management.aimdo_allocator = None
198+
elif comfy_aimdo.control.init_device(comfy.model_management.get_torch_device().index):
196199
if args.verbose == 'DEBUG':
197200
comfy_aimdo.control.set_log_debug()
198201
elif args.verbose == 'CRITICAL':
@@ -208,7 +211,7 @@ def execute_script(script_path):
208211
comfy.memory_management.aimdo_allocator = comfy_aimdo.torch.get_torch_allocator()
209212
logging.info("DynamicVRAM support detected and enabled")
210213
else:
211-
logging.info("No working comfy-aimdo install detected. DynamicVRAM support disabled. Falling back to legacy ModelPatcher. VRAM estimates may be unreliable especially on Windows")
214+
logging.warning("No working comfy-aimdo install detected. DynamicVRAM support disabled. Falling back to legacy ModelPatcher. VRAM estimates may be unreliable especially on Windows")
212215
comfy.memory_management.aimdo_allocator = None
213216

214217

0 commit comments

Comments
 (0)