Nodes/AUN ComfyUI Nodes/AUN Clean VRAM
ComfyUI Node

AUN Clean VRAM

Drop the model before the decode spike, without leaving the graph

By loz2754·Created 9 months ago·Updated 18 days ago· 7
AUN Clean VRAM
  • anything
  • output

ComfyUI is pretty good at memory management right up until it isn't. It loads what a node needs, keeps it warm in case the next queue wants it again, and only throws things out when pressure builds. Leave it alone and it does the right thing on a normal SDXL graph. Then you build a video pipeline - a 33B diffusion model, a Qwen3-VL-class text encoder, a turbo LoRA, a video VAE and an audio VAE, all in one graph - and the timing of that eviction stops being invisible.

AUN Clean VRAM is the blunt instrument you reach for when the automatic heuristics guess wrong. It's a pass-through node with exactly one job: when it executes, it unloads every cached model and empties the CUDA cache, then hands you back whatever you fed it. Nothing in between, no conditions, no widgets.

What it actually does

The whole implementation is two calls:

comfy.model_management.unload_all_models()
comfy.model_management.soft_empty_cache()

Both sit inside a try/except that logs and moves on, so a cleanup failure won't kill your run. "Soft" is worth noticing - this is a request, not a guarantee, and it's why VRAM sometimes stays high in nvidia-smi afterwards.

Two source details make it behave inside a real workflow. It's registered as an output node (OUTPUT_NODE = True), so ComfyUI always schedules it instead of pruning it as a dead branch. And its IS_CHANGED returns NaN, so the cache never skips it - it fires on every queue, which is what you want here and would be a bug anywhere else.

Inputs and outputs

There's one input and one output, and they're both *:

  • anything (optional, socket-only) - the author's tooltip: "Any value to pass through. Connect the output that should trigger the VRAM cleanup (e.g. the sampled LATENT)."
  • output - the same object you put in, unchanged.

So you chain it rather than use it as a side node: KSampler LATENT → anything, output → VAE Decode's latent input. The value threads through untouched; the cleanup is the side effect that happens at that point in the graph.

Install

ComfyUI Manager → search "AUN ComfyUI Nodes" → install → restart. Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/loz2754/AUN-ComfyUI-Nodes

The pack's requirements.txt (installed by Manager or install.py) pulls piexif, opencv-python-headless, imageio-ffmpeg and requests - none of which this node needs. Its own description says "no external dependencies", and that's accurate: it's just comfy.model_management. If you cloned manually and see ModuleNotFoundError: piexif or cv2 from some other AUN node, that's the pack-level install you skipped:

pip install -r custom_nodes/AUN-ComfyUI-Nodes/requirements.txt

Custom nodes all share one Python environment, so a pack install is never entirely free - worth knowing before you blame this node for anything.

Where to put it, and where people get burned

The intended slot is between the sampler and the VAE decode - the position the author mirrors from the MiniMax-H3 reference workflows, where a CleanVRAM node sits before decode. That placement makes sense once you've watched a run: sampling runs the big model, but decode is where the latent expands into pixels and the peak allocation lands, one step after you stopped needing the U-Net.

  • You pay a reload. ComfyUI reloads lazily, so the model comes back from disk when the next node needs it. On a 20GB+ video model that's real seconds. This node trades time for headroom, always - never the other way round.
  • It won't make anything faster. If your graph fits comfortably, adding it can only slow you down.
  • It can't free what isn't ComfyUI's. Memory held by other processes, or spilled into Windows' shared GPU memory via sysmem fallback, is out of reach. That's the recurring shape of the complaint in the wild: flushing ComfyUI's cache clears physical VRAM but the shared pool stays occupied and the next workflow still OOMs. This node is the fix people get handed for it - and sometimes it isn't enough.
  • Wire it. Leaving anything empty technically still runs the cleanup, but the node executes wherever the scheduler puts it in the queue, with no relationship to your actual pipeline. The point is where it fires.

Before you add it, try the built-in: ComfyUI's "Free model and node cache" button does the same eviction by hand. If that fixes the OOM mid-crisis, this node is just that fix automated. If it doesn't, your problem is elsewhere - quantize, lower the resolution, or shave frames off the length.

CategoryAUN Nodes/Utility

Inputs (1)

NameTypeDefaultDescription
anythingopt*Any value to pass through. Connect the output that should trigger the VRAM cleanup (e.g. the sampled LATENT).

Outputs (1)

NameTypeDescription
output*—