Nodes/Eric_Krea2/Eric Krea2 Unload Models
ComfyUI Node

Eric Krea2 Unload Models

Reclaim VRAM without restarting ComfyUI

By EricRollei·Created 2 months ago·Updated about a month ago· 11
Eric Krea2 Unload Models
  • value
  • krea2_pipeline
  • value
also_clear_module_cachestrue
aggressive_teardowntrue
also_unload_comfy_modelstrue
verbosetrue

A 12B model eats VRAM for breakfast, and Krea 2's diffusers pipeline is heavier than a stock ComfyUI checkpoint load - the transformer, the Qwen3-VL text encoder, the VAE, plus whatever attention backend you picked. When you want that memory back mid-session, Eric Krea2 Unload Models is the eject button. It frees the pipeline on demand instead of forcing a restart.

How it works

This is a plumbing node in the best sense - it exists to fight graph state, not pixels. It takes a value input of any type (the wildcard *), which you wire with anything already in your graph - say, the final IMAGE - so the node sits downstream and actually runs as part of the queue. Then it works through three optional hooks, all on by default:

  • krea2_pipeline - the pipeline to free. Connect the Loader's krea2_pipeline output here.
  • also_clear_module_caches - clears the loader nodes' module-level _COMP_CACHE/_PIPELINE_CACHE, not just the connected pipe. Leave it on unless you have a second pipeline you're deliberately keeping alive.
  • also_unload_comfy_models - also unloads what ComfyUI's own model_management is tracking (SAM, GroundingDINO, DepthPro, anything loaded through regular nodes), then soft-empties ComfyUI's cache.

aggressive_teardown is the interesting one. Instead of relying on the top-level pipe object's refcount hitting zero, it explicitly breaks the pipe's internal references to transformer/vae/text_encoder and shoves them to the meta device before dropping the pipe. The tooltip is candid about why: something - an accelerate hook, a cached attention workspace, an offload dispatch table - can be holding a submodule reference independent of the pipe wrapper. That's the "I unloaded and VRAM didn't drop" situation this toggle exists for. Leave it on.

verbose (default on) prints refcount plus CUDA memory before and after, which tells you whether something else is genuinely holding a reference or whether it's driver/kernel-level memory that only frees on process exit. That diagnostic output is the difference between "the node is broken" and "the driver is lying to you."

It returns value unchanged, so your graph keeps flowing - the unload is a side effect riding the queue, not a branch.

Install

Part of Krea2_ComfyUI_Advanced (Eric Hiss / EricRollei), self-contained:

cd ComfyUI/custom_nodes
git clone https://github.com/EricRollei/Krea2_ComfyUI_Advanced

Restart, or install via ComfyUI Manager. The pack needs a diffusers build with Krea2Pipeline - the --force-reinstall install from the HF git repo in the README is the step people miss.

Where it bites

Nodes that cache in their own globals are invisible to this - the tooltip names SegmentAnything Ultra with cache_model=True - so turn their own cache toggles off too. If VRAM still doesn't drop after unload with verbose on, read the refcount line: refcount near zero with memory not returned means the driver holds it, and nothing in Python can fix that. And if you unload the pipeline a loader is caching, the pack's other nodes know how to recover an empty dict (VAE Encode does it silently) - but your next generation pays the full reload cost, so this is a between-workflows tool, not a mid-run toy.

CategoryEric/Krea2

Inputs (6)

NameTypeDefaultDescription
value*Passthrough - wire anything here (e.g. the final IMAGE) so this node sits downstream in the graph and runs as part of the queue.
krea2_pipelineoptKREA2_PIPELINEThe pipeline to free. Connect the Component Loader or plain Loader's krea2_pipeline output here.
also_clear_module_cachesoptBOOLEANtrueAlso clear the loader nodes' module-level caches (_COMP_CACHE / _PIPELINE_CACHE), not just this input. Leave ON unless you specifically want to free only the connected pipeline and keep another cached one alive.
aggressive_teardownoptBOOLEANtrueExplicitly break the pipe's internal references to its submodules (transformer/vae/text_encoder) before dropping the pipe itself, instead of relying on the top-level pipe object's refcount hitting zero on its own. Use this when 'keep in vram'=True on the loader and VRAM isn't dropping after unload - something (accelerate hooks, cached attention workspace, an offload dispatch table) may be holding a submodule reference independent of the pipe wrapper.
also_unload_comfy_modelsoptBOOLEANtrueAlso unload models ComfyUI's own model_management is tracking (SAM / GroundingDINO / DepthPro and anything else loaded through regular comfy nodes), then soft-empty comfy's cache. NOTE: nodes that cache in their own globals (e.g. SegmentAnything Ultra with cache_model=True) are invisible to this - turn their own cache toggle off as well.
verboseoptBOOLEANtruePrint refcount + CUDA memory before/after, to diagnose cases where VRAM still doesn't drop (tells us whether something else is holding a reference, vs. it being driver/kernel-level memory that only frees on process exit).

Outputs (1)

NameTypeDescription
value*