ComfyUI Node

Painter VRAM

Make ComfyUI stop taking the whole card, without restarting it

By princepainter·Created 8 months ago·Updated 2 days ago· 193
Painter VRAM
  • anything
  • output
  • reserved_gb
reserved0.6
modeauto
clean_gpu_beforetrue
auto_max0.0
seed0

The normal way to stop ComfyUI from swallowing your whole GPU is a launch flag, --reserve-vram, which means closing ComfyUI, editing your start script, and restarting every time you want to change it. Painter VRAM does the same thing from inside the graph, and adds an auto mode that measures what the card is currently using before deciding.

That's the pitch. Here's the honest framing: reserving VRAM makes things slower, not faster. You're telling ComfyUI it may not use some memory, which for a model that filled the card means offloading. On a 12 GB card that could just barely hold fp8 Klein, one measured A/B found roughly a 2x speedup came from removing --lowvram --reserve-vram 11 - the low-VRAM safety rails were costing more than they saved. So reach for this node when something else genuinely needs the card (a game, a browser with a video call, a local LLM), not as a default.

What it sets

mode defaults to auto. In auto it reads GPU memory from NVML if pynvml is available, falls back to torch.cuda.mem_get_info(), and if neither works it just uses your manual number. Then it reserves already-in-use + your margin, so other applications keep the memory they've already claimed.

  • reserved - default 0.6 GB. The margin on top of measured usage in auto mode, or the exact figure in manual mode. It accepts negatives (down to -2) - in auto that means "reserve less than what's already in use", and anything that resolves below zero gets clamped to 0.
  • auto_max - a cap on the auto result. Default 0, which is off. Handy when you measured 6 GB of desktop use once, but don't want a stray session with two browsers open to reserve 12.
  • clean_gpu_before - default on. Does gc.collect(), unloads all models and empties ComfyUI's cache before measuring. That ordering isn't cosmetic: measure first and ComfyUI's own loaded models get counted as "already in use", which inflates the reservation badly. The flip side is that turning this on means your resident models get evicted and reloaded, so if you're mid-session and just want to nudge the budget, turn it off.
  • seed - decides caching. Auto mode reads a live number, so a cached result goes stale the moment another application opens. The default 0 caches; -1 recomputes on every run. If you set this once and your reservation seems frozen at an old value, that's why.

There's also an optional wildcard input, anything, and a matching wildcard output, plus reserved_gb - the figure it actually applied, rounded to two decimals. Wire reserved_gb into a text or preview node if you want proof of what happened rather than reading the console.

The node is an output node, so it runs even if nothing downstream consumes it. Park it at the bottom of the graph like a note.

The DynamicVRAM detail

ComfyUI's newer dynamic memory manager (comfy-aimdo) keeps its own headroom and never looks at the EXTRA_RESERVED_VRAM global - so assigning that global alone does nothing visible while DynamicVRAM is active. This node writes both: the classic global, and aimdo.set_simple_vram_headroom() when it detects aimdo is enabled and loaded, which is the same thing ComfyUI itself does with --reserve-vram at boot. If the aimdo sync fails it logs and carries on, because the global is already set.

That matters in practice more than it sounds. Version dumps from 2026 installs routinely show comfy-aimdo alongside ComfyUI, and people running 32 GB cards with --reserve-vram 6 still hit OOM on big video models - reserving memory doesn't create it, it only declines to use some. If your reservation seems to have no effect, DynamicVRAM is the first thing to check, and it's the exact case this node was written for.

Installing it

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

Or search PainterNodes in ComfyUI Manager. Requirements are soundfile and numpy for the pack as a whole; the node itself only needs pynvml for the preferred auto path, which isn't in the pack's requirements so it may simply be absent - in that case you'll see the node fall back to torch, and on a non-NVIDIA card NVML won't initialise at all. The import is wrapped, so that's a log line rather than a broken node pack.

Where people get burned

Setting a reservation and forgetting it. Manual mode reserves exactly what you typed for the rest of the session, so a value you set while running a game sticks around when the game closes and now just costs you speed. Auto mode with seed left at 0 has the opposite failure: it keeps a stale measurement. Use auto with seed: -1 if you want it to track reality, and remember the node changes a module global - it's a session-wide setting the moment it executes, not a per-node property.

CategoryVRAM

Inputs (6)

NameTypeDefaultDescription
reservedFLOAT0.6-2–64
modeCOMBOauto2 options: manual, auto
clean_gpu_beforeBOOLEANtrue
auto_maxFLOAT0.00–64
seedINT0-1–1125899906842624
anythingopt*

Outputs (2)

NameTypeDescription
output*
reserved_gbFLOAT