ComfyUI Extension: comfyui-memory-manager
Run ComfyUI workflows without the setup
No installs, no CUDA version roulette, no GPU sitting idle on your bill. Bring a workflow and run it in the browser.
ComfyUI custom nodes for preventing OOM crashes with real-time VRAM monitoring, automatic model unloading, LRU cache, and memory budget gates.
Looking for a different extension?
Custom Nodes (0)
README
ComfyUI Memory Manager
ComfyUI custom nodes for preventing OOM crashes — real-time VRAM monitoring, automatic model unloading, LRU cache, and memory budget gates.
The Problem
ComfyUI hordes VRAM until it crashes. Even on a 4090 with 64GB RAM, complex workflows with multiple model loads (base + refiner + upscaler + LoRAs) exceed hardware limits. The built-in "Clear RAM" nodes don't work. You must manually separate workflow stages and clear between them.
The Solution
Drop these nodes into your workflow to manage memory automatically:
# Copy to ComfyUI custom_nodes/
cp -r comfyui-memory-manager/ ComfyUI/custom_nodes/
Nodes
| Node | Description |
|------|-------------|
| 📊 VRAM Monitor | Real-time VRAM usage display |
| 🧹 Force Cleanup | Garbage collection + CUDA cache clear |
| 🚦 Memory Budget Gate | Block execution if insufficient VRAM |
| ⚙️ Set Cache Size | Set max VRAM budget for model cache |
| 📈 Cache Stats | Show cached models and their sizes |
Usage
Monitor VRAM
Add VRAM Monitor to any point in your workflow. It outputs a string with current VRAM stats:
VRAM: 8234MB / 16384MB (50.2%)
Reserved: 9100MB | Free: 7284MB
Auto-Cleanup Between Stages
Connect ForceCleanup between model-heavy stages:
[Load Checkpoint] → [Force Cleanup] → [Load LoRA] → [KSampler]
Memory Budget Gate
Prevent OOM by gating expensive operations:
[Load SDXL] → [Memory Budget Gate (required_mb=4000)] → [KSampler]
↓ status: "OK — 7284MB available (need 4000MB)"
LRU Model Cache
The SetCacheSize node configures an LRU cache that automatically evicts least-recently-used models when VRAM fills up.
Installation
cd ComfyUI/custom_nodes
git clone https://github.com/darshd9941/comfyui-memory-manager.git
cd comfyui-memory-manager
pip install -r requirements.txt
How It Works
- VRAM Monitor queries
torch.cudafor real-time memory stats - Force Cleanup runs
gc.collect()+torch.cuda.empty_cache()+torch.cuda.synchronize() - Memory Budget Gate checks free VRAM before allowing downstream nodes to execute
- LRU Cache tracks loaded models and evicts least-recently-used ones when budget exceeded
- Cache Stats inspects the LRU cache to show what's loaded
Requirements
- ComfyUI (latest)
- PyTorch with CUDA
- Python 3.9+
License
MIT License — see LICENSE for details.
Run ComfyUI workflows without the setup
No installs, no CUDA version roulette, no GPU sitting idle on your bill. Bring a workflow and run it in the browser.