凤希AI - 释放资源
The end-of-run housekeeper that stops long batches from dying on you
- 输入
FxAiReleaseResources is the pack's answer to a very specific, very annoying failure mode: your workflow runs fine for two segments, then the third one dies with an out-of-memory error even though each segment is tiny. The usual culprit isn't the size of one segment - it's the junk that piles up across them. Cached models you're not using, VRAM held hostage by a no-longer-needed tensor, Python garbage that never got collected. ComfyUI's memory management is decent, but on a low-VRAM machine running a long looping video pipeline, "decent" isn't enough. This node is the scheduled housekeeper you bolt onto the end of each iteration.
The mechanism is real, not cosmetic - it reads the actual ComfyUI internals. On every run it does four things: calls soft_empty_cache() to flush ComfyUI's own cache, optionally unload_all_models() to kick every loaded checkpoint off the GPU, then torch.cuda.empty_cache() plus ipc_collect() to reclaim CUDA memory, and finally gc.collect() for Python-side garbage. On Windows it also trims the process working set via the kernel API, which is the classic fix for the "memory keeps climbing every run" problem on that OS. It's a solid, grounded cleanup - the same levers the community reaches for manually when a machine slowly drowns (troubleshooting.md in the KB covers the VRAM-management side).
The interface is honest about its two toggles: 卸载所有模型 (unload all models, default on) and 清空CUDA显存 (clear CUDA cache, default on). There's a required 输入 port of type * - that's a dummy pass-through so you can chain it after whatever the run produces without breaking the graph. It returns nothing and is marked as an output node, so it always executes.
Where people get burned: unchecking is sometimes the right call. If 卸载所有模型 is on, it unloads everything - including the checkpoint the next segment is about to reload. That costs you a model reload every loop iteration, which on a slow disk can be slower than the memory you save. If your batch is dying, leave it on; if it's just slow, try turning it off and keeping only the CUDA clear. And remember this node runs at the end of whatever chain it's in - put it after your save/preview nodes, not before, or you'll clean up mid-segment.
It ships as part of fxai-toolkit (凤希AI / fxai.site). ComfyUI Manager → search "fxai-toolkit" or "凤希", or:
cd ComfyUI/custom_nodes
git clone https://github.com/fxai666/fxai-toolkit
Restart after cloning; the pack auto-installs soundfile and psutil on first load. If you're doing long unattended renders, this is one of the pack's genuinely useful ideas - a resource valve you can schedule into the loop instead of babysitting the console.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| 输入 | * | — | |
| 卸载所有模型opt | BOOLEAN | true | — |
| 清空CUDA显存opt | BOOLEAN | true | — |
Outputs (0)
No outputs