Nodes/ComfyUI Layer Style/LayerUtility: Purge VRAM
ComfyUI Node Runs on cloud

LayerUtility: Purge VRAM

PurgeVRAM — dump the model cache between heavy stages

By chflame163·Created 3 years ago·Updated 4 days ago· 3,113
LayerUtility: Purge VRAM
  • anything
    â—„purge_cachetrueâ–º
    â—„purge_modelstrueâ–º

    If a workflow blows up with a CUDA out-of-memory error the moment it tries to load a second big model - even though the first one is finished - this is the node that fixes it. PurgeVRAM unloads resident models and clears the cache on demand, freeing GPU memory partway through the graph instead of at the end. It's the original version of a trick people lean on hard in memory-tight pipelines; in one popular LTX-Video thread, adding a purge node cut VRAM usage almost in half.

    How it works

    Normally ComfyUI keeps models parked in VRAM between runs so it doesn't have to reload them - fast, but it's why two large models that each fit alone won't fit back to back. PurgeVRAM forces the eviction: it unloads loaded models from the GPU and flushes the torch allocator cache, the same cleanup ComfyUI does on a reload, triggered where you put the node.

    It's a terminal (output) node - it doesn't pass anything downstream, it just runs and frees memory. That's the one real difference from PurgeVRAM V2, which adds a pass-through output so you can splice it inline and control ordering. Use V2 if you need the purge to happen between two specific stages; use this one when you just want a hard flush after a branch finishes.

    The inputs that matter

    There are only three, and two are booleans:

    • anything - accepts any type. It's the trigger: feed it the output of the stage you want to happen before the purge, so ComfyUI's dependency graph runs this node at the right time.
    • purge_cache (default on) - clears the torch/Python cache.
    • purge_models (default on) - unloads models from VRAM. The heavy lifter.

    No outputs. Leave both toggles on unless you're deliberately keeping something resident.

    How to install it

    Via ComfyUI Manager: open the Custom Nodes Manager, search ComfyUI Layer Style, install, restart. Or from a terminal:

    cd ComfyUI/custom_nodes
    git clone https://github.com/chflame163/ComfyUI_LayerStyle
    

    install requirements.txt into ComfyUI's Python and restart. It's a big pack, so the first launch is slow. Find the node under 😺dzNodes → LayerUtility → SystemIO.

    Common issues and the honest take

    Because it's a dead-end node with no output, its timing is entirely decided by what you feed anything. Wire it to the output of the stage you want flushed; if you leave anything disconnected, the node has no place in the dependency order and may not run when you expect. That's the single most common "it's not doing anything" complaint.

    The honest note: installing the entire Layer Style compositing suite for one memory-flush node is a lot of dependency for a little utility. That exact reaction shows up in the community - someone in the LTX thread switched to a lighter single-purpose "free memory" node once they realized they didn't need the rest of the pack. If you're already running Layer Style, this is free and handy. If PurgeVRAM is all you want, a standalone VRAM node is the leaner choice. And if you want to insert the purge mid-chain rather than at a dead end, reach for PurgeVRAM V2 instead.

    Category😺dzNodes/LayerUtility/SystemIO

    Inputs (3)

    NameTypeDefaultDescription
    anything*—
    purge_cacheBOOLEANtrue—
    purge_modelsBOOLEANtrue—

    Outputs (0)

    No outputs