VRAM Purge (Inline)
Force ComfyUI to actually give VRAM back
- passthrough
- passthrough
"VRAM Purge (Inline)" is a boring little node that solves a very real problem: after a VLM has run, ComfyUI doesn't always hand the VRAM back, and the next big step OOMs for no obvious reason. Drop this node in the middle of a workflow and it forces a full cleanup - then passes your value through untouched.
It ships with the ComfyUI-VLMPrompt pack for a reason. The pack's whole deal is chaining a local vision-language model into a diffusion workflow, and VLMs are greedy: a model can stay resident or leave reserved memory behind after it's done. When the sampler then tries to load a big checkpoint on a 12GB card, that leftover reservation is exactly what tips it over. The purge node is the band-aid, and a decent one.
How it works
The node calls ComfyUI's own cleanup sequence directly: unload_all_models(), gc.collect(), then torch.cuda.empty_cache() plus ipc_collect() and a synchronize() for good measure. It prints the result to the console in the form:
[VRAMPurge] Done. Allocated: 0.31 GB, Reserved: 1.02 GB
That readout is actually useful - you can see, in real numbers, how much VRAM the VLM was holding and how much the purge recovered. No CUDA? It prints "Done (no CUDA)" and moves on.
The interface
It's about as minimal as a node gets: no required inputs, one optional passthrough that accepts any type, and one output passthrough of the same type. Wire any value in - an image, a string, a model object - and it comes out the other side unchanged, after the purge runs. That's the whole trick: the passthrough gives you a place to sit in the graph without disrupting data flow.
Where to put it
The obvious spot is right before the heavy node in a VLM → sampler chain: VLM prompt node → VRAM Purge → your image/video model. Because ComfyUI executes nodes in dependency order, wiring your value through the purge guarantees the cleanup happens before the resource-hungry step. It also makes a handy manual "flush" if you just want to force a reload of a model in a long session.
Install
Same pack install:
cd ComfyUI/custom_nodes
git clone https://github.com/mexxmillion/ComfyUI-VLMPrompt.git
pip install -r ComfyUI-VLMPrompt/requirements.txt
Restart ComfyUI. No models to download, no extra dependencies beyond what ComfyUI already has (torch and comfy.model_management), and - unlike the VLM nodes in this pack - no llama-cpp-python or transformers requirement. It works even if the rest of the pack's backends fail to load.
Common issues
- "No effect" - if nothing was holding memory, the purge does nothing dramatic. That's success, not a bug.
- Purge ran but OOM still happens - the purge can't shrink what a loaded model genuinely needs. Unload the model, or use it before the big step, not after.
- Forgetting the pass-through - if you don't wire anything through it, the node still runs when reached; but wiring it inline is what gives you deterministic ordering.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| passthroughopt | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| passthrough | * | — |