Nodes/ComfyUI_EmAySee_CustomNodes/EmAySee Selective Model Unloader
ComfyUI Node

EmAySee Selective Model Unloader

Free one model's VRAM without nuking the checkpoint you still need

By EmAySee·Created about a year ago·Updated 4 months ago· 2
EmAySee Selective Model Unloader
  • image
  • image
  • unloaded_count
  • debug_info
model_name_filterModelConfig
deep_gc_scanfalse
exclude_checkpointstrue
unload_modemove_to_cpu
purge_cachetrue

ComfyUI's default memory management is mostly fine: it keeps the currently-loaded models in VRAM, offloads when you run low, and the "free model and node cache" button nukes everything when you're stuck. The problem is the "everything" part. If your workflow uses a checkpoint plus a SAM segmenter plus a vision model, and you want to drop just the segmenter back to CPU while keeping the checkpoint resident, the stock tools won't do it selectively. That's the gap EmAySee Selective Model Unloader fills - it's the surgical version of the free-cache button.

It comes paired with its inverse, the EmAySee Selective Model Reloader, which moves the same models back. Think of them as a matching set: run one to evict, run the other to restore, both inside the same graph or from a second pass.

How it works

The node walks comfy.model_management.current_loaded_models, the internal list ComfyUI uses to track what's resident, and checks each loaded model's class name against your filter. Because it inspects the model's model_config type (things like SDXL, Flux, SVD_img2vid, Wan, and friends), it can also tell a checkpoint apart from a peripheral model - which matters, because you usually want to protect checkpoints from eviction.

  • model_name_filter - comma-separated substrings matched case-insensitively against model class names. "*" matches everything. Default is "ModelConfig", which catches pretty much any ComfyUI model whose config class is named that - start with a more specific filter or you'll evict more than you meant to.
  • exclude_checkpoints - when on (default), checkpoint-type models are protected and skipped.
  • unload_mode - move_to_cpu (default) just moves the model off the GPU; delete_references drops it from current_loaded_models so it has to be re-loaded from disk next time.
  • deep_gc_scan - a blunt second pass: walks every live Python object, finds torch.nn.Modules on CUDA matching the filter, and moves them to CPU. This catches models that slipped out of ComfyUI's own registry. It's slow and it's a hack, but it's also how you actually get that stubborn SAM off the card.
  • purge_cache - on by default; runs gc.collect() and soft_empty_cache(), and with exclude_checkpoints off it fully replicates the "free model and node cache" backend (clears node cache, unloads all models).

The image input is a passthrough - the node doesn't touch your image, it just uses the wire to sit in the graph so it executes at the right point. That's a ComfyUI idiom you'll see a lot in this pack.

Outputs you'll actually read

  • image - your input image, untouched.
  • unloaded_count - how many models got evicted. Wire this into a text preview or just read the value.
  • debug_info - a string log of what was unloaded ("Standard Unload: SDXL…") and what was protected. This is the node telling you what it did; if you get "No matches found", your filter doesn't match the model's class name.

Installing it

Part of ComfyUI_EmAySee_CustomNodes (search Manager for the pack title, or git clone https://github.com/EmAySee/ComfyUI_EmAySee_CustomNodes into custom_nodes/, then restart). No requirements.txt, no model downloads - it leans on ComfyUI's own model_management internals, so nothing heavy to install.

Where people get burned

The filter is fuzzy by design, and fuzzy means you can catch models you didn't mean to. "ModelConfig" as a default matches broadly; if you're unloading "everything except X" instead of "just X", you want a targeted class name. The other trap: unloading a model that a later node still needs mid-graph just forces ComfyUI to reload it, which is slower than not unloading it at all. Use this node in workflows where you know the model's work is done - typically at the end of a stage, before a heavy sampler starts. If you're not sure what's actually loaded, read the debug_info string first; that's exactly what it's for.

CategoryEmAySee/Utils

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
model_name_filterSTRINGModelConfig
deep_gc_scanBOOLEANfalse
exclude_checkpointsBOOLEANtrue
unload_modeCOMBOmove_to_cpu2 options: move_to_cpu, delete_references
purge_cacheBOOLEANtrue

Outputs (3)

NameTypeDescription
imageIMAGE
unloaded_countINT
debug_infoSTRING