DGLS Cleanup
The 'give my VRAM back' node for when a DGLS run leaves your card in a weird state
- trigger
- output
The DGLS pack gets all its attention from the two loaders: the Model Loader preps the model and the Swapping Loader shuffles layers in and out of VRAM. This third node is the boring one nobody writes about. It's an output node you drop at the end of a workflow, and its entire job is to unload models and clear memory. Not glamorous - but it ships with the pack for a real reason.
That reason: DGLS is aggressive with memory. It pins layers, holds master weights on CPU, swaps blocks mid-sampling. Run a few heavy generations back to back and you can end up with the next run OOMing on a card that should handle it fine - not because anything leaked, but because the previous run left the card holding state it no longer needs. This node is the targeted reset, the "give me a clean slate without restarting the whole server" button.
How it works
It's a pass-through with a side effect. You feed it a trigger (any type - usually the output of your last real node, so it fires when the run finishes) and it passes that value straight back out on output. In between it cleans house.
With use_comfy_clear on (the default), it calls ComfyUI's own unload_all_models() and soft_empty_cache(True) - the same "Clear Cache All" the UI exposes. Then it goes further than ComfyUI's built-in does: torch.cuda.empty_cache(), a Python garbage collection pass, a CUDA synchronize, and an IPC collect to tidy up cross-process memory. If verbose is on (also default), it prints a post-cleanup diagnosis: how many GB are still allocated versus reserved, how many models ComfyUI still has loaded, and a warning if more than about half a gigabyte is still sitting there.
When to actually use it
Honest take: for a normal single-image workflow, you don't need it. ComfyUI manages its caches well enough on its own, and adding cleanup nodes to every graph is the kind of cargo-cult habit that clutters workflows for no benefit. Reach for it in two specific situations:
- Iterating on DGLS settings. When you're tuning
prefetch, residency, orcast_targetand want each run to start from a clean card rather than whatever the last run left behind, this is cheaper than restarting ComfyUI. - Debugging a suspected leak. Keep
verboseon and the diagnosis tells you whether the problem is a real leak (memory still allocated after cleanup) or just a loaded model ComfyUI is holding onto - which are very different things to chase.
That's the whole node. The inputs are three - trigger, use_comfy_clear, verbose - and the default values are all the sensible ones. If you need it, it's there; if you don't, you'll forget it exists, and that's fine.
Installing it
Same as the rest of the pack - it arrives with obisin/ComfyUI-DGLS, so installing the pack gives you all three nodes.
cd ComfyUI/custom_nodes
git clone https://github.com/obisin/ComfyUI-DGLS
cd ComfyUI-DGLS
pip install -r requirements.txt
Or grab it through ComfyUI Manager by searching for ComfyUI-DGLS, then restart. One note for the manual path: the README's own clone command references a stale dgls-comfyui URL - the real repo is obisin/ComfyUI-DGLS. And don't skip the requirements install; the pack needs bitsandbytes and friends for its full feature set. Like the rest of this pack, it's a pre-release project from a solo dev, so treat it as a tool to understand rather than something to blindly trust with your one working workflow.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| trigger | * | — | |
| use_comfy_clearopt | BOOLEAN | true | Use ComfyUI's built-in Clear Cache All function |
| verboseopt | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| output | * | — |