显存预留管理
Tell ComfyUI to leave some VRAM alone — before it OOMs mid-workflow
- vram_info
ComfyUI's memory manager is greedy by design: it grabs as much VRAM as it thinks it can use, unloads models only when it has to, and has no idea you planned to run an LLM caption node later in the same workflow. ReservedVRAMNode is the "hands off, that's mine" sign. You tell it how many gigabytes to keep aside, and ComfyUI's memory manager respects that headroom instead of filling every byte.
It comes from the AIGCZero/ComfyUI-tools_zero pack, and it's the odd one out in two ways: it's the only node in the pack categorized under "Zero工具" rather than the shared tools category, and its whole job is memory management - the enabling condition for the pack's other headline features. The source openly credits an earlier project, Windecay/ComfyUI-ReservedVRAM, so think of this as the pack author's take on that idea. If you're running this pack's Qwen2_prompt or Qwen2VL_prompt nodes alongside diffusion, this is the node that keeps the sampler and the LLM from fighting over the same card.
What it does
One input, reserved_gb (0–48, step 0.1). Set it to, say, 4 and the node writes that into comfy.model_management.EXTRA_RESERVED_VRAM (in bytes) - the same knob the --reserve-vram launch flag turns, but live, mid-session, per-workflow. Set it to 0 and you're back to ComfyUI's default behavior.
The output is a vram_info string, formatted and readable, telling you total VRAM, currently allocated, reserved, free, and what your reservation is set to. It's not a tensor or an image - it's a text report you read, or wire into a text-display node if you want it on the canvas.
It also does a bit of frontend service: the pack registers API routes (/reserved_vram/info, /set, /get) and a toolbar widget that polls and shows your VRAM stats every five seconds, so you get a live readout of whether your reservation is actually being honored.
How it works
The setting is process-global: a module-level variable plus the EXTRA_RESERVED_VRAM override on ComfyUI's memory manager. Once set, ComfyUI treats that much VRAM as unavailable and adjusts its unload/offload decisions around it - so the next time the sampler decides whether to keep your diffusion model resident, it leaves your reserved space alone.
Installing it
Same pack install as everything else. ComfyUI Manager → search "ComfyUI-tools_zero", or:
cd ComfyUI/custom_nodes
git clone https://github.com/AIGCZero/ComfyUI-tools_zero
Restart after cloning. It's pure CPU-side bookkeeping - no model downloads, no VRAM cost of its own, and it works on any CUDA setup.
Where people get burned
Two things. First, the reservation is global and in-process: it applies to everything ComfyUI does after this node runs, not just your workflow - and it's reset when ComfyUI restarts. If a workflow feels inexplicably slower or you're seeing "not enough memory" where you didn't before, check whether a ReservedVRAMNode set a big reservation that's still in effect. Second, it's a bookkeeping knob, not a guarantee - reserve 12GB on an 8GB card and you've just told ComfyUI to work with negative space; nothing will save you from that. Be conservative: a few GB is the sweet spot, and the honest use case is "I know a model loads later in this graph, so keep this much free." If you're juggling an LLM node and the sampler in one graph, pair it with the pack's Zero_CleanCache to actively unload models between stages rather than just reserving space.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| reserved_gb | FLOAT | 0.00–48 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| vram_info | STRING | — |