EmAySee Selective Model Unloader
Free one model's VRAM without nuking the checkpoint you still need
- image
- image
- unloaded_count
- debug_info
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_referencesdrops it fromcurrent_loaded_modelsso it has to be re-loaded from disk next time.deep_gc_scan- a blunt second pass: walks every live Python object, findstorch.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; runsgc.collect()andsoft_empty_cache(), and withexclude_checkpointsoff 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.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| model_name_filter | STRING | ModelConfig | — |
| deep_gc_scan | BOOLEAN | false | — |
| exclude_checkpoints | BOOLEAN | true | — |
| unload_mode | COMBO | move_to_cpu | 2 options: move_to_cpu, delete_references |
| purge_cache | BOOLEAN | true | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| unloaded_count | INT | — |
| debug_info | STRING | — |