强力清除缓存
Unload the LLM, free the VRAM, and keep the queue moving
- 输入数据
- 输出数据
Every ComfyUI user with a 12GB card has had the same moment: the LLM prompt node just finished, the diffusion sampler is up next, and the "CUDA out of memory" wall hits because both models wanted the same VRAM. Zero_CleanCache is a drop-in cleanup node that sits between those two stages. When the queue runs through it, it tells ComfyUI's backend to unload models and free memory, optionally pauses a few seconds so the dust settles, then passes your data straight through. It's the manual version of the automatic unload/reload that good local-LLM workflows build in - except you decide when it fires.
It ships in AIGCZero/ComfyUI-tools_zero, the same pack as the Qwen2_prompt and Qwen2VL_prompt nodes it's designed to clean up after. Those nodes already free their own model when keep_model_loaded is off, but they don't unload the diffusion models ComfyUI is holding - that's the gap this fills.
What it does
Four inputs, one output, and the magic is the wildcard: the input and output are * type, which in ComfyUI means "accept anything." You can thread this node in front of anything - a latent, an image, a text string - and it passes the data through byte-for-byte. Its job isn't transformation, it's timing.
- 卸载模型 (unload models, default on) - asks the backend to unload loaded models.
- 释放内存 (free memory, default on) - asks it to free the torch cache.
- 停止时间 (stop time, 0–10 seconds) - pause the workflow this long after cleaning, so VRAM actually gets returned before the next heavy node runs.
- 输入数据 (input data, any type) - the passthrough.
Output is 输出数据, the same data you put in. Under the hood it POSTs to ComfyUI's own /free endpoint - the same call you can make by hand:
curl -X POST http://127.0.0.1:8188/free -H "Content-Type: application/json" \
-d '{"unload_models": true, "free_memory": true}'
How it works
Nothing clever, and that's the appeal. The node is a ComfyUI-side trigger: when it executes, it fires the HTTP request, sleeps your chosen seconds, and returns the input unchanged. Because it's wildcard-typed, ComfyUI lets you drop it almost anywhere in the graph, and because it returns its input, it doesn't disturb the data flow - you can even run several in different branches of one workflow.
Installing it
Standard pack install. ComfyUI Manager → search "ComfyUI-tools_zero", or:
cd ComfyUI/custom_nodes
git clone https://github.com/AIGCZero/ComfyUI-tools_zero
Restart after cloning. It needs no models, no extra dependencies beyond what the pack installs, and it costs no VRAM itself.
Where people get burned
Three gotchas worth knowing. First, the endpoint URL is hardcoded to port 8188 - if you run ComfyUI with a custom --port, the cleanup silently fails and the node just passes data through. Same for the pack's Qwen nodes, which call the same endpoint. Second, the node only helps if it executes - ComfyUI skips nodes whose inputs haven't changed, so if your cleanup node sits behind a cached branch it may not fire when you expect; put it somewhere the graph always runs. Third, the pause is a blocking sleep on the queue: set 停止时间 to 10 and everything waits 10 seconds. That's the point when you need unload time, but it'll feel like a hang if you don't remember you set it. Used properly - one cleanup step between the caption/expand stage and the sampler - it's the cheapest fix for the two-models-one-card problem.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| 卸载模型 | BOOLEAN | true | — |
| 释放内存 | BOOLEAN | true | — |
| 停止时间 | INT | 00–10 | — |
| 输入数据 | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| 输出数据 | * | — |