ComfyUI Node

Clean GPU

A sledgehammer for VRAM, not a magic fix

By adrianschubek·Created about a year ago·Updated about a year ago· 1
Clean GPU
  • input
  • output

Run a big workflow long enough and VRAM slowly fills with cached models, intermediates, and tensors ComfyUI thinks it might need again. ZeugCleanGpuPass is the pack's answer: drop it on a wire, and when the graph passes through it, it aggressively empties the GPU cache - then hands your data through untouched. It sounds like a cure-all for OOM errors. It is not. Here's what it actually does, because the details decide whether it helps you or makes things slower.

What it is

ZeugCleanGpuPass lives in the zeug → Extra menu. One input, input (any type), one output, output (the same data, passed through). When it executes it prints Cleaning VRAM... to the console and runs a full sweep:

  • gc.collect() - collects Python garbage
  • torch.cuda.empty_cache() - releases cached CUDA memory back to the driver
  • torch.cuda.ipc_collect() - cleans up inter-process CUDA memory
  • comfy.model_management.soft_empty_cache() and cleanup_models() - ComfyUI's own cache tidying
  • model_mgmt.unload_all_models() - unloads every loaded model

Then it returns your input unchanged.

The honest take

That last call is the one that matters. This is not a gentle "free a little headroom" node - it nukes the model cache. If you place it between a sampler and an upscaler, the upscaler's model (and every checkpoint, LoRA, and VAE ComfyUI was holding) gets dropped from VRAM, and the next step has to reload everything from disk. On a big model, reloading can take longer than the memory you just saved cost you.

So where does it genuinely help? Two cases:

  • Recovering from a one-off OOM. If a workflow dies on VRAM and you want to clear the slate before retrying, this is a fine way to do it.
  • Freeing VRAM for a separate heavy pass where reloading is an acceptable one-time cost - e.g., clearing cached models before a big video decode or a huge upscale.

Where it will bite: inside loops, batch iterations, or anywhere you run it repeatedly - each pass forces full reloads, and your run gets dramatically slower, not faster. Treat it as a once-per-workflow reset, not a per-step habit.

How it works (the mechanism)

Under the hood it's a passthrough whose side effect is the cleanup sequence above. One honest limitation: the CUDA calls only do anything on NVIDIA hardware. On Apple Silicon (MPS) or CPU-only builds, torch.cuda.empty_cache() is effectively a no-op and the real work is just ComfyUI's own cache cleanup - so the node is largely cosmetic there. And because it's a passthrough, the input/output are always identical; the only observable effect is the console message and the VRAM state.

How to install it

Ships in comfyui-zeug (German for "gear" or "stuff"), a small GPL-3.0 pack by Adrian Schubek:

  • ComfyUI Manager: search zeug in the Custom Nodes Manager, install ComfyUI-Zeug.
  • Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/adrianschubek/comfyui-zeug

Restart ComfyUI. Zero dependencies, no model downloads - the pack only uses torch and ComfyUI's built-in model management.

Common issues

The main one is expectations. People drop this in expecting it to prevent OOM; instead they get slower runs from constant reloading. Before reaching for it, remember ComfyUI already manages VRAM fairly automatically - the real levers for fitting big models on small cards are quantization (GGUF), tiling, and not stacking models you don't need. Use this node as a deliberate reset between major phases, not a per-step insurance policy. Done that way, it's a useful emergency valve.

Categoryzeug/extra

Inputs (1)

NameTypeDefaultDescription
input*

Outputs (1)

NameTypeDescription
output*