Nodes/ComfyUI-DistorchMemoryManager/General Purge VRAM V2
ComfyUI Node

General Purge VRAM V2

The zombie LayerStyle node that now also nukes SeedVR2, Qwen3-VL, Nunchaku, HSWQ and Ollama

By ussoewwin·Created 11 months ago·Updated 5 days ago· 51
General Purge VRAM V2
  • anything
  • any
purge_cachetrue
purge_modelstrue
purge_seedvr2_modelsfalse
purge_qwen3vl_modelsfalse
purge_nunchaku_modelsfalse
HSWQfalse
Ollamafalse

This is the flagship node of the pack, and its backstory is the reason it exists. LayerStyle's Purge VRAM V2 used to be a staple in video upscaling workflows, then it vanished from the upstream pack and everyone with a saved workflow started seeing "missing nodes" errors on load. This node keeps those legacy workflows alive under the same class name, and then kept growing. Every version added another specialty purge, and it's now the thing you reach for when a model's memory won't go away no matter what you unload.

It's a passthrough - ANY in, ANY out, exactly like the original. What differs is how much machinery runs between the two sockets.

The two toggles that do the classic thing

  • purge_cache (default True) - gc.collect(), then empty_cache() and ipc_collect() on every CUDA device. The basic "give the memory back to the driver" move.
  • purge_models (default True) - the aggressive unload: cleanup_models() to drop dead models, cleanup_models_gc(), marks everything unused, calls model_unload(). This is the part that made the original node famous, and it still works.

The specialty toggles - why you'd pick this node at all

ComfyUI only knows about memory it manages itself. A bunch of recent tooling holds VRAM outside model_management, and stock unload can't see it. That's the gap these target:

  • purge_seedvr2_models - clears SeedVR2's own GlobalModelCache (both DiT and VAE) and releases through SeedVR2's own release_model_memory(). SeedVR2 caches models independently of ComfyUI, which is exactly why upscalers built on it leak.
  • purge_qwen3vl_models - hunts Qwen3-VL models in sys.modules and live Python objects, handles the device_map="auto" case where a model is split across devices.
  • purge_nunchaku_models - FLUX/Z-Image/Qwen-Image/SDXL models running on Nunchaku's quantized engine. These hide inside wrapper classes (NunchakuFluxTransformer2dModel and friends), and the node disables CPU offload, clears caches, and releases roughly 2.5GB of VRAM on the SDXL path.
  • HSWQ - a full purge for the HSWQ stack: drains its PinCache, clears PromptExecutor/SEGS caches in place, and resets the CUDA workspace so the next run still works.
  • Ollama - calls Ollama's own API (/api/generate and /api/chat with keep_alive=0, then ollama stop) until /api/ps reports nothing loaded. This targets models loaded by comfyui-ollama and comfyui-ollama-describer, including the describer's default keep_model_alive=-1 which would otherwise keep a model resident forever.

All five default to False. Good. Don't enable them speculatively - each one is a targeted wrecking ball for a specific stack. Enable only what your workflow actually uses, and keep purge_cache/purge_models on.

Installing it

ComfyUI Manager (search "Distorch" or "VRAM Manager"), or:

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

Dependencies are minimal (torch, psutil, nvidia-ml-py). Restart and the node lands under Distorch/Memory.

The honest warnings

First, legacy compatibility cuts both ways: this is a clone that has diverged a lot, and a workflow saved against the original LayerStyle node may expect slightly different behavior than what v2.4.x ships. Second, this is a big hammer. purge_models is intentionally aggressive - it can unload models the scheduler still wanted, so placing it mid-prompt (rather than between stages) can cause a re-load penalty or a hiccup. And like every node in this pack, it's a small one-maintainer project with a fast changelog, so don't auto-update without glancing at what changed. If a model you're purging refuses to die, the fix is usually the specialty toggle, not a stronger purge_models.

CategoryDistorch/Memory

Inputs (8)

NameTypeDefaultDescription
anything*
purge_cacheBOOLEANtrue
purge_modelsBOOLEANtrue
purge_seedvr2_modelsBOOLEANfalseClear SeedVR2 DiT (base) and VAE models from cache
purge_qwen3vl_modelsBOOLEANfalseClear Qwen3-VL models from GPU memory
purge_nunchaku_modelsBOOLEANfalseClear Nunchaku models (FLUX/Z-Image/Qwen-Image) from GPU memory
HSWQBOOLEANfalsePurge HSWQ residual VRAM (whole HSWQ path: models, PinCache, Detailer caches)
OllamaBOOLEANfalseFull purge of Ollama VRAM used by comfyui-ollama and comfyui-ollama-describer: unload every loaded model until /api/ps is empty (generate+chat keep_alive=0, ollama stop), clear CHAT_SESSIONS/saved_context, wipe saved_context files

Outputs (1)

NameTypeDescription
any*