Clear Model
Freeing GPU memory to load the next model
- any
- model
- tokenizer
- any
Every loader node in this pack has an is_locked toggle, and locked (the default) means the model stays resident in memory across runs instead of reloading from disk every single execution - good for speed, bad if you actually want to swap models mid-session. Clear Model is the other half of that mechanism: the node you route through, with is_locked disabled on the loader, when you actually want to release a model from GPU or RAM before loading a different one, rather than restarting ComfyUI entirely just to free memory.
The model input is required - this is the loaded model object you want released, coming from whichever loader you used (GGUF Loader, VLM Loader, Easy Local LLM Loader, whatever). tokenizer is optional, for models where the loader also produced a separate tokenizer object that needs releasing alongside the model. is_ollama is worth calling out specifically: if the model you're clearing came from Ollama rather than one of this pack's own local loaders, flip this on - Ollama manages its own model lifecycle differently from a directly-loaded transformers or GGUF model, and this flag tells the node to handle the unload the Ollama-appropriate way rather than trying to release memory this pack's local loaders manage directly.
The any input and output are the part worth understanding rather than skipping past, because they're not really about data - they're a common ComfyUI trick for forcing execution order. ComfyUI runs nodes based on data dependencies, not top-to-bottom position on the canvas, so if you want Clear Model to run after some other step finishes (say, after your LLM has actually produced its final response, so you're not clearing a model mid-use), you wire that other node's output into any here, whatever type it happens to be - the wildcard * type accepts anything. That forces this node to wait until the thing you plugged in has actually run. The any output lets you chain the same trick further downstream if something after this needs to wait for the clear to finish first.
Installing it means installing the whole pack: search "comfyui_LLM_party" in ComfyUI Manager, or git clone https://github.com/heshengtao/comfyui_LLM_party into custom_nodes and restart, then run pip install -r requirements.txt from inside the pack folder using ComfyUI's own Python (portable installs: python_embeded\python.exe -m pip install -r requirements.txt, not your system pip).
Where this actually earns its place in a workflow: if you're building anything that loads more than one local model in sequence - comparing two models' responses, running a small model for a quick task and a bigger one for the real work - without Clear Model in between, you're stacking memory usage rather than swapping it, and you'll hit an out-of-memory error that looks like it's coming from the second loader when it's really just that the first model never got released. The fix isn't more VRAM, it's remembering to disable is_locked on the loader you're done with and route it through this node before the next one loads. And if you're clearing an Ollama-backed model and it doesn't seem to actually free anything, double check is_ollama is set - using this node's default (non-Ollama) release path against an Ollama model is the kind of mismatch that fails quietly rather than with a clear error.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| any | * | — | |
| model | CUSTOM | — | |
| is_enable | BOOLEAN | true | — |
| tokenizeropt | CUSTOM | — | |
| is_ollamaopt | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| any | * | — |