ComfyUI-DistorchMemoryManager Introduction
ComfyUI-DistorchMemoryManager is a specialized extension designed to enhance memory management within the ComfyUI environment. This extension is particularly beneficial for AI artists who work with complex video generation workflows, such as upscaling, which can often lead to out-of-memory (OOM) errors. These errors are typically due to system RAM shortages rather than VRAM shortages, even on systems with substantial RAM. By efficiently managing both GPU and CPU memory, ComfyUI-DistorchMemoryManager helps prevent these issues, ensuring smoother and more reliable performance during intensive tasks.
How ComfyUI-DistorchMemoryManager Works
At its core, ComfyUI-DistorchMemoryManager operates by optimizing memory usage through a series of custom nodes. These nodes are designed to clear unnecessary data from memory, manage model loading and unloading, and perform garbage collection. Imagine your computer's memory as a workspace cluttered with tools and materials. This extension acts like a diligent assistant, tidying up the workspace by putting away tools that are no longer needed, thus freeing up space for new tasks. This process helps prevent the workspace from becoming too cluttered, which can slow down or halt your work.
ComfyUI-DistorchMemoryManager Features
Model Patch Memory Cleaner
This feature is specifically designed for workflows involving ModelPatchLoader. It clears model patches to prevent OOM errors during upscaling. By ensuring that only necessary data is retained in memory, it helps maintain optimal performance.
- Options:
clear_model_patches: Removes model patches.clean_gpu: Clears GPU memory.force_gc: Forces garbage collection.
Purge VRAM V2 Compatibility
This node restores and enhances the LayerUtility: Purge VRAM V2 functionality, supporting various models like SeedVR2, Qwen3-VL, and Nunchaku. It aggressively unloads models and clears caches to free up memory.
- Options:
purge_cache: Clears caches and performs garbage collection.purge_models: Unloads unused models.purge_seedvr2_models: Clears SeedVR2 models.purge_qwen3vl_models: Clears Qwen3-VL models.purge_nunchaku_models: Clears Nunchaku models.
Memory Manager (Advanced)
This node offers comprehensive memory management for advanced users, allowing detailed control over memory clearing processes.
- Options:
clean_gpu: Clears GPU memory.clean_cpu: Clears CPU memory (use cautiously).force_gc: Forces garbage collection.reset_virtual_memory: Resets virtual memory.
Patch Sage Attention DM
An experimental feature that replaces ComfyUI's standard attention mechanism with SageAttention, improving memory efficiency and performance.
- Options:
sage_attention: Selects SageAttention mode.allow_compile: Enables torch.compile for SageAttention.
Troubleshooting ComfyUI-DistorchMemoryManager
Common Issues and Solutions
- Out of Memory Errors: Use the Model Patch Memory Cleaner or Memory Manager nodes to clear unnecessary data and free up memory.
- OOM During Upscaling: Ensure the Model Patch Memory Cleaner is used after ControlNet usage and before upscaling.
- UI Corruption: Avoid enabling
clean_cpuunless necessary, as it may cause UI issues. - OOM with Specific Models: Use the Purge VRAM V2 node with appropriate options to clear model-specific memory.
Learn More about ComfyUI-DistorchMemoryManager
For further assistance and resources, consider exploring community forums and tutorials that focus on memory management in AI workflows. Engaging with these communities can provide valuable insights and support, helping you make the most of the ComfyUI-DistorchMemoryManager extension.
