Unload Models
Sick of restarting ComfyUI to free VRAM? This node unloads models for you
- any_input
- any_output
ComfyUI keeps a loaded checkpoint in VRAM long after your image is done, and that's by design - it's what makes the next generation feel instant. The problem is when you're not generating anymore. You want to run a video, fire up an LLM on the same box, or just hand the GPU back to the rest of your machine, and ComfyUI is still squatting on 8GB of VRAM. The classic fix is restarting the whole process, which is slow and loses your session state. This node - the MemoryTools_UnloadModels "Unload Models" node from the comfyui-memory-tools pack - ends that. Drop it at the end of a workflow and it frees the loaded models for you automatically, every single run.
The pack's story (briefly)
This is one of three ways the pack frees memory: two icon-only buttons in the top bar (vacuum-cleaner icons, top right) and this node. The buttons unload on demand; the node unloads automatically. The author built it after ComfyUI Manager's old "Unload Models" top-bar buttons vanished - a real complaint in the community, where people hit memory problems and end up restarting the whole app. The pack is a small personal project (the author calls it "vibe coded"), MIT-licensed, with zero Python dependencies and no model downloads. It's as close to risk-free as a custom node gets.
How it works
The node is an output node in the utils/memory category, which matters more than it sounds. ComfyUI executes output nodes at the end of every queue run - that's the same mechanism behind Preview Image and Save Image always running - so putting this node in your graph guarantees it fires after every generation, no matter which branch of the workflow produced the result.
Under the hood it calls ComfyUI's own memory machinery, the same thing the built-in unload function uses: unload_all_models(), then gc.collect(), then soft_empty_cache() to tell the CUDA allocator to give the memory back. Nothing custom, nothing fragile. If you pick the second mode it also sets a free_memory flag on the prompt queue, which clears ComfyUI's execution cache - the stored results that let it skip unchanged nodes.
The inputs that matter
mode- the only one you'll set.unload modelsjust frees the models;unload models + execution cache(the default) also drops the cache so the next run re-executes everything fresh.any_input/any_output- an optional wildcard passthrough. The node itself is a terminal; the*types just let you chain it after something like a VAE Decode and forward the image out the other side to more nodes. Wire nothing in and it still works fine.
Install
Via ComfyUI Manager: Custom Nodes Manager → search "Memory Tools". Or the manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/rghvdberg/comfyui-memory-tools
Restart ComfyUI. That's it - no requirements.txt to fight with, no extra dependencies to break your environment, no model files to download.
Where people get burned
The tradeoff is in the README and it's the whole game: unloading means the next generation pays a model-reload cost. If you batch-queue twenty images with this node in the workflow, every single image reloads the checkpoint first, and your batch gets slower for no memory benefit. This node earns its keep in two situations: you're sharing the GPU with other work and want memory free between jobs, or you're on a card tight enough that a cold next run beats a swapping OOM. The second mode's cache-clear also makes the next run recompute everything - handy when you suspect stale cached results, but slightly slower. One more thing: it runs at the end of a generation, so it won't save you if a single heavy job is already OOMing mid-run. For that you want a smaller quant, not this node.
If you find yourself staring at the task manager wondering why ComfyUI still owns your VRAM, this is the one to reach for.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| mode | COMBO | unload models + execution cache | 2 options: unload models, unload models + execution cache |
| any_inputopt | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| any_output | * | — |