Nodes/Comfy_HunyuanImage3/Hunyuan 3 Force Unload (Nuclear)
ComfyUI Node

Hunyuan 3 Force Unload (Nuclear)

The last resort that actually frees stuck VRAM

By EricRollei·Created 10 months ago·Updated 4 months ago· 65
Hunyuan 3 Force Unload (Nuclear)
  • trigger
  • cleared
  • memory_report
  • unload_signal
first_run_onlyfalse
clear_all_modelstrue
aggressive_gctrue
reset_cuda_allocatortrue
clear_comfy_cachetrue
nuke_orphaned_tensorsfalse
nuke_ram_tensorsfalse

Let's be honest about what this node is for: the other 11 months of the year you don't need it. Hunyuan 3 Force Unload (Nuclear) (class HunyuanImage3ForceUnload) is the emergency crew for the days when Hunyuan 3 has eaten your 80GB+ of VRAM, ComfyUI "forgot" about an allocation, and even a normal unload won't budge it. The "Nuclear" is in the name because the author means it - this node can clear every cached model in ComfyUI, not just Hunyuan.

The scenario that makes it genuinely worth having wired in: cross-tab VRAM pollution. If you keep workflows open in multiple browser tabs, models loaded from other tabs stay in VRAM but ComfyUI's cache no longer tracks them. Your next run then fails with a fake OOM. That's exactly the case the README calls out, and it's the one where Nuclear earns its place in a permanent workflow.

How it works

It's a stack of memory-blasters, each independently toggleable:

  • clear_all_models (default True) - clears the Hunyuan model cache.
  • aggressive_gc (default True) - three passes of garbage collection.
  • reset_cuda_allocator (default True) - resets the CUDA memory allocator; the thing to reach for after an OOM.
  • clear_comfy_cache (default True) - clears ComfyUI's internal model cache. The tooltip warns this affects all models, not just Hunyuan. Flux and SAM2 included. This is why the node is nuclear.
  • nuke_orphaned_tensors (default False) - hunts down stray Hunyuan CUDA tensors. The author scopes it to Hunyuan, so it's safe for downstream models - use it when VRAM is stuck after an OOM.
  • nuke_ram_tensors (default False) - same idea for leaked Hunyuan tensors in system RAM, for when your RAM fills with weights that should've been freed.

The one setting to care about

first_run_only (default False) is the clever bit. Set it True and the node does its full cleanup on the first execution of a workflow run, then auto-skips every subsequent run. That's the pattern for a multi-run session: the first run wipes the pollution from other tabs, and your successive runs keep Hunyuan loaded and fast instead of re-nuking it. For the "clean once, then keep rolling" workflow it's the difference between Nuclear being a one-time fix and a recurring foot-gun.

There's also an optional trigger input (any type) and three outputs: cleared (BOOLEAN), memory_report (STRING), and unload_signal (wildcard). The signal output is useful - wire it into a loader's unload_signal input (the INT8 Budget loader has one) to sequence a clean load after the purge instead of racing it.

How to install it

It's part of the Comfy_HunyuanImage3 pack:

cd ComfyUI/custom_nodes
git clone https://github.com/EricRollei/Comfy_HunyuanImage3
cd Comfy_HunyuanImage3
pip install -r requirements.txt

Restart ComfyUI and hard-refresh the browser. Or install via ComfyUI Manager (search HunyuanImage).

Common issues & troubleshooting

Don't use this for routine cleanup. It clears everything - your next run will pay a full reload on every model, and with Hunyuan that's a multi-minute cold start. For day-to-day, the README's utility-node matrix has the right mapping: Soft Unload for fast model switching, plain Unload for standard cleanup, Nuclear only when VRAM is genuinely stuck or polluted from another tab.

If you're running this after an OOM and VRAM still looks full, enable nuke_orphaned_tensors - that's the setting that reaches allocations the normal cache-clearing path can't see. And on multi-GPU boxes, the README suggests pairing this with the GPU Info node to confirm what torch.cuda actually sees before you start blasting.

CategoryHunyuanImage3

Inputs (8)

NameTypeDefaultDescription
first_run_onlyBOOLEANfalseOnly run on FIRST execution, then auto-skip. Perfect for cleaning up cross-tab pollution while keeping Hunyuan loaded for successive runs.
clear_all_modelsBOOLEANtrueClear Hunyuan model cache
aggressive_gcBOOLEANtrueRun aggressive garbage collection (3 passes)
reset_cuda_allocatorBOOLEANtrueReset CUDA memory allocator (may help after OOM)
clear_comfy_cacheBOOLEANtrueClear ComfyUI's internal model cache (affects all models!)
nuke_orphaned_tensorsBOOLEANfalseHunt and destroy orphaned Hunyuan CUDA tensors. Safe for downstream models (scoped to Hunyuan only). Use after OOM when VRAM is stuck.
nuke_ram_tensorsBOOLEANfalseHunt and destroy orphaned Hunyuan CPU tensors in RAM. Safe for downstream models (scoped to Hunyuan only). Use when system RAM is full of leaked model weights.
triggeropt*

Outputs (3)

NameTypeDescription
clearedBOOLEAN
memory_reportSTRING
unload_signal*