Nodes/raylight/Clean VRAM Used (Raylight)
ComfyUI Node

Clean VRAM Used (Raylight)

The 'please empty my VRAM' node

By komikndr·Created about a year ago·Updated 2 days ago· 409
Clean VRAM Used (Raylight)
  • anything
  • output

Running a Raylight workflow is a long-session hobby. Models stay loaded, latents pile up, and by the third run your VRAM is a museum of everything you've touched since lunch. RayCleanVRAMUsed is a tiny utility node that exists to sweep the floor: it frees the VRAM owned by the ComfyUI host process, then passes your input straight through. The tooltip says it exactly - "Frees VRAM owned by the ComfyUI process, then passes this value through."

How it works. Under the hood it does the three-step memory dance: garbage-collect Python objects, unload all loaded models, then soft-empty the cache. That's gc.collect() plus ComfyUI's unload_all_models() and soft_empty_cache() under the hood. Nothing clever, nothing destructive - it frees what ComfyUI is holding and leaves your workflow graph untouched.

The inputs that matter. Just one: anything. The type is *, meaning it accepts any wire - a latent, an image, a conditioning, a number, anything. The "anything" is a graph trick: since the node has to run for the graph to complete, you wire something into it so ComfyUI actually executes the cleanup at the right point. It's an output node, so you place it at the end of a workflow - often as a branch off your final preview or save - and it fires when that branch runs.

Output. output, type *, which is whatever you fed in, unchanged. The pass-through is the point: you can hang the cleanup off a save node without breaking the flow.

Where it fits. In the Raylight context, this is more useful than the equivalent core nodes, because the pack keeps models resident in Ray workers between runs and long multi-step workflows (video especially) accumulate host-side memory. It's the "reset the state between heavy jobs" node - put it at the end of a workflow you run in a loop, or at the end of a big run before you switch to a different model. Note the scope: it frees the host process's VRAM. The Ray workers hold their own copies of the model, so this doesn't evict what the workers have cached - for that you'd restart ComfyUI or let the pack's own worker management handle it.

One honest word of caution: don't drop it mid-workflow as a band-aid. If you're OOMing between steps, the real fix is usually model offloading, FSDP, or fewer things in memory at once - this node just empties the bucket, it doesn't fix the leak.

Install. Part of the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/komikndr/raylight
cd raylight
pip install -r requirements.txt

or ComfyUI Manager → search "raylight" → Install, restart. No model files, no extra dependencies beyond the pack's normal ones (xfuser is the big one); FlashAttention is optional; Windows means WSL2.

It's not the node anyone searches for, but it's the node that lives in every serious multi-run workflow - a one-wire broom you'll be glad is there when the third consecutive Wan run starts coughing.

CategoryRaylight

Inputs (1)

NameTypeDefaultDescription
anything*Frees VRAM owned by the ComfyUI process, then passes this value through.

Outputs (1)

NameTypeDescription
output*