Kiko Purge VRAM
The VRAM Pressure-Relief Valve That Sits Right in Your Graph
- anything
- passthrough
- memory_report
If you've ever had a workflow die with "CUDA out of memory" in the middle of a long run, you've wanted what this node does: a fire-and-forget VRAM purge you can drop anywhere in the graph. Kiko Purge VRAM runs garbage collection and clears ComfyUI's CUDA cache at a point you choose, and it passes whatever data flows through it along unchanged. It's a checkpoint valve, not a data processor - the input goes in one side and comes out the other, memory a little emptier.
How it works
The mechanism is exactly what you'd want it to be: it calls Python's gc.collect() and torch.cuda.empty_cache(), and in its heavier modes can unload all loaded models via ComfyUI's model_management (which is what actually frees the big chunks - a checkpoint sitting in VRAM is usually the memory hog, not the cache). It reads memory stats before and after, so you get a real report of how many MB it freed and how long it took, instead of a hope and a prayer.
Four modes are available:
- soft - basic garbage collection plus cache clear. Default, and usually enough.
- aggressive - multiple GC passes, synchronizes the GPU, clears cache and IPC. The "I'm genuinely stuck" option.
- models_only - unloads every model and clears the model cache, without touching the rest. Best before a different model takes over.
- cache_only - just clears the CUDA cache, no GC.
The memory_threshold_mb input makes it conditional: set it to, say, 4000 and the node only purges when usage is already above that, leaving things alone when you're fine. 0 (the default) means always purge.
Inputs and outputs
- anything - the passthrough. Any type; it goes in, it comes out.
- mode - one of the four above.
- report_memory - toggle the before/after report.
- memory_threshold_mb (optional) - only purge above this threshold.
Outputs: passthrough (whatever you fed in) and memory_report (a STRING with the stats, handy if you want to display it).
Where it shines
Real-world cred: people hit exactly the "works once, then progressively slower until it OOMs" pattern with long video workflows, and the fix people actually reach for is this node. One community report described being unable to run an animation workflow even quantized, then adding this node between the VAE output and the save node and having it "work great." That placement is the trick: purge between stages - after a decode, before an upscale, between model swaps - rather than at the very end where it helps nothing.
Installing it
Pack install, one time: ComfyUI Manager → "ComfyUI-KikoTools" → Install → restart, under ComfyAssets → Utils. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/ComfyAssets/ComfyUI-KikoTools.git
cd ComfyUI-KikoTools
pip install -r requirements.txt
Gotchas
Don't expect it to save you from a fundamentally too-big model - purging frees cache and unused models, not the checkpoint currently in use. If OOM hits mid-sample, this won't fix that run. Also, models_only is blunt: it unloads everything, so anything after it in the graph will reload models fresh (slower, but memory-clean). And on non-CUDA setups it degrades gracefully to a no-op report, so don't use it as a system health check.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| anything | * | — | |
| mode | COMBO | soft | Purge mode: soft (basic), aggressive (thorough), models_only (unload models), cache_only (clear cache) |
| report_memory | BOOLEAN | true | Generate detailed memory usage report |
| memory_threshold_mbopt | INT | 00–48000 | Only purge if memory usage exceeds this threshold (0 = always purge) |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| passthrough | * | — |
| memory_report | STRING | — |