mm: Remove Aimdo exemption for empty_cache (#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.
This commit is contained in:
@@ -1724,11 +1724,9 @@ def soft_empty_cache(force=False):
|
|||||||
elif is_mlu():
|
elif is_mlu():
|
||||||
torch.mlu.empty_cache()
|
torch.mlu.empty_cache()
|
||||||
elif torch.cuda.is_available():
|
elif torch.cuda.is_available():
|
||||||
if comfy.memory_management.aimdo_allocator is None:
|
torch.cuda.synchronize()
|
||||||
#Pytorch 2.7 and earlier crashes if you try and empty_cache when mempools exist
|
torch.cuda.empty_cache()
|
||||||
torch.cuda.synchronize()
|
torch.cuda.ipc_collect()
|
||||||
torch.cuda.empty_cache()
|
|
||||||
torch.cuda.ipc_collect()
|
|
||||||
|
|
||||||
def unload_all_models():
|
def unload_all_models():
|
||||||
free_memory(1e30, get_torch_device())
|
free_memory(1e30, get_torch_device())
|
||||||
|
|||||||
7
main.py
7
main.py
@@ -192,7 +192,10 @@ import comfy_aimdo.control
|
|||||||
import comfy_aimdo.torch
|
import comfy_aimdo.torch
|
||||||
|
|
||||||
if enables_dynamic_vram():
|
if enables_dynamic_vram():
|
||||||
if comfy_aimdo.control.init_device(comfy.model_management.get_torch_device().index):
|
if comfy.model_management.torch_version_numeric < (2, 8):
|
||||||
|
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")
|
||||||
|
comfy.memory_management.aimdo_allocator = None
|
||||||
|
elif comfy_aimdo.control.init_device(comfy.model_management.get_torch_device().index):
|
||||||
if args.verbose == 'DEBUG':
|
if args.verbose == 'DEBUG':
|
||||||
comfy_aimdo.control.set_log_debug()
|
comfy_aimdo.control.set_log_debug()
|
||||||
elif args.verbose == 'CRITICAL':
|
elif args.verbose == 'CRITICAL':
|
||||||
@@ -208,7 +211,7 @@ if enables_dynamic_vram():
|
|||||||
comfy.memory_management.aimdo_allocator = comfy_aimdo.torch.get_torch_allocator()
|
comfy.memory_management.aimdo_allocator = comfy_aimdo.torch.get_torch_allocator()
|
||||||
logging.info("DynamicVRAM support detected and enabled")
|
logging.info("DynamicVRAM support detected and enabled")
|
||||||
else:
|
else:
|
||||||
logging.info("No working comfy-aimdo install detected. DynamicVRAM support disabled. Falling back to legacy ModelPatcher. VRAM estimates may be unreliable especially on Windows")
|
logging.warning("No working comfy-aimdo install detected. DynamicVRAM support disabled. Falling back to legacy ModelPatcher. VRAM estimates may be unreliable especially on Windows")
|
||||||
comfy.memory_management.aimdo_allocator = None
|
comfy.memory_management.aimdo_allocator = None
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user