Nodes/Bjornulf_custom_nodes/🧹 Free VRAM hack
ComfyUI Node

🧹 Free VRAM hack

Force ComfyUI to actually let go of memory

By justUmen·Created 2 years ago·Updated about a year ago· 545
🧹 Free VRAM hack
  • anything
  • *

ComfyUI caches loaded models in VRAM deliberately - it's what makes queuing up multiple runs with the same checkpoint fast, since it doesn't reload from disk every time. That's a feature most of the time. But if you're done with a heavy model and want the memory back for something else - switching to a completely different pipeline, running a memory-hungry TTS server alongside image generation, or just checking your card is actually free before starting something new - ComfyUI doesn't give you an easy button for that. This node is the author's own attempt at building one.

He's upfront that it's exactly that: a hack, not an official feature. In his own words, from the README: "this is my attempt at freeing up VRAM after usage, I will try to improve that... I don't think there is a clean way to do that, so I'm using a hacky way." On his own machine, freshly launched ComfyUI idles around 180MB of VRAM; after a session of use, this node's cleanup gets it back down to roughly 376MB rather than staying pinned at whatever a loaded checkpoint left behind - not a full return to baseline, but a meaningful chunk of memory back.

How it works

Under the hood it triggers an "empty" dummy workflow run to force ComfyUI's own memory management to release what it's holding - which is also why the effect isn't instant. Expect a few seconds' delay after your actual workflow finishes before the memory actually drops. There's one hard requirement to make it work at all: you need dev/api mode enabled in ComfyUI's own settings. Without that turned on, this node can't do what it needs to do.

The inputs and outputs that matter

Just one of each, and the type is a wildcard: anything in, * out, unchanged. Like the pack's Note node, this is a transparent pass-through - you drop it anywhere in an existing chain (after the last node that needs the model still loaded, typically) and it does its cleanup as a side effect of executing, without altering the data flowing through it.

Installing it

Through ComfyUI Manager: search Bjornulf_custom_nodes, install, restart. Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/justUmen/Bjornulf_custom_nodes

Install the shared requirements.txt afterward, and separately, go into ComfyUI's Settings and enable dev/api mode - this node is nonfunctional without it, and that's not something the pack's own requirements file can fix for you.

Where people get burned

Forgetting to enable dev/api mode is the number one reason this node appears to do nothing at all - check that setting first if you drop this in and your VRAM usage doesn't budge. Second: the author's own caution is worth repeating, because it cuts against the instinct to just leave this node in every workflow "to be safe" - ComfyUI's caching exists specifically to make repeated runs with the same checkpoint fast, and this node works against that by design. Sprinkle it in everywhere and you'll pay a reload cost every time, for VRAM headroom you didn't actually need in that moment. Use it at the genuine pinch points - before switching pipelines, before starting something VRAM-hungry alongside image generation - not as a reflexive habit after every run.

CategoryBjornulf

Inputs (1)

NameTypeDefaultDescription
anything*

Outputs (1)

NameTypeDescription
**