Nodes/comfyui-obvpm/Clean VRAM (obvpm)
ComfyUI Node

Clean VRAM (obvpm)

Free the card mid-graph, and know the cost

By chanon·Created about a month ago·Updated a day ago· 40
Clean VRAM (obvpm)
  • anything
  • output

Here's the classic ComfyUI failure: the graph runs fine, then dies at the VAE decode, or at the upscaler, with an out-of-memory error - even though no single node in it needs more VRAM than you have. What's happening is that everything stays resident. The text encoder, the UNet, the VAE, the upscale model, all still loaded, all still holding memory, because ComfyUI caches models on the assumption you might want them again in a second.

Clean VRAM is the blunt instrument for exactly that moment. It unloads every loaded model and releases the cached VRAM, in the middle of your graph, on purpose.

What it does

It takes one input, anything, and gives it straight back out as output. It doesn't touch the value at all - its entire job is to sit somewhere in execution order. Under the hood it runs the three calls ComfyUI exposes for this:

gc.collect()
mm.unload_all_models()
mm.soft_empty_cache()

Then it logs that it did. That's it. There are no options, because there's nothing to configure: it either unloads everything or it doesn't exist.

The one design decision worth understanding is that it's declared an output node. Normally a node whose result nobody consumes gets pruned before it runs - ComfyUI works backwards from the output nodes and skips what contributes nothing. A pure passthrough whose output dangles would therefore never execute, and the cleanup would never happen. Being an output node makes it an execution root, so it runs whether or not anything downstream wants the value.

How to place it

Put it on the wire between two stages that can't both be in memory. The anything input is usually fed by whatever the previous stage produced - a latent, an image, a model - and you wire output onward into the next stage. You're not doing anything with the value; you're ordering the cleanup before the consumer.

A concrete example: sample a long video at big resolution, then decode. Wire whatever the sampler hands you through Clean VRAM and into the decode. The sampler's models are gone by the time decode needs the room.

You can place more than one. There's nothing stateful about it.

The cost, stated plainly

Everything it unloads reloads on next use, from disk, into VRAM. On a 20GB checkpoint plus a 12GB text encoder, that's not a rounding error - it's tens of seconds and a hard drive read every single run. So this is not a "make workflows faster" node and it's not a "make ComfyUI more efficient" node. It's the node you reach for when the alternative is the run failing.

Place it where the reload is cheaper than the OOM. Between the sample and the decode of a video, where the decode is a small model and the sampler's weights are huge, it's often a good trade. Between two nodes that share a model, it's a pure loss.

What it is not

It's not a substitute for a smaller model. The KB's VRAM guidance for ComfyUI is unchanged by this node: on a constrained card the lever that actually works is a quantised checkpoint - GGUF or fp8 - plus realistic resolution, and the text encoder is now a second VRAM budget of its own on modern architectures, not an afterthought. Clean VRAM buys you a gap between stages, not headroom inside one. If a single node OOMs, no amount of unloading before it will help.

Two smaller gotchas. First, the node comes from this pack, and the sequence it runs is ComfyUI's own API used the obvious way - the pack credits ComfyUI-Easy-Use's easy cleanGpuUsed as the design it's replacing, so if you're migrating off that pack, this is the drop-in. Second, it unloads all models; if you're mid-iteration with a second workflow queued, expect that one to pay a full reload too.

Install

Manager, search comfyui-obvpm. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/chanon/comfyui-obvpm

Restart, and type obvpm in the node search menu to see the whole pack. No extra Python packages, no model files, no configuration. The pack's pyproject.toml declares no dependencies at all, deliberately - everything it imports already comes with ComfyUI, and re-pinning torch or numpy on your install would only invite a conflict.

Categoryobvpm/misc

Inputs (1)

NameTypeDefaultDescription
anything*Passed through untouched. Its only job is to place the cleanup in execution order.

Outputs (1)

NameTypeDescription
output*The input, unchanged. Wire it onward so the cleanup is ordered before whatever needs the room.