Nodes/ComfyUI-VLMPrompt/VRAM Purge (Start)
ComfyUI Node

VRAM Purge (Start)

Purge once at the start of the workflow, before the VRAM hogs wake up

By mexxmillion·Created 4 months ago·Updated 4 months ago· 2
VRAM Purge (Start)
    • trigger_text
    • trigger_int
    purge_on_starttrue

    "VRAM Purge (Start)" is the sibling of "VRAM Purge (Inline)" with a different job: instead of sitting mid-graph passing data through, it sits at the front of a workflow, runs one full cleanup the moment execution starts, and hands you a trigger signal so you can force it to run first. One purge, right at the top, before anything big loads.

    The use case is the long session. You've been running experiments, models are half-unloaded, and you kick off a big workflow - only for the first heavy node to trip over memory that a previous run left behind. Dropping this trigger at the front means every run starts from a clean slate, which makes the run itself far more reproducible when you're chasing an OOM.

    How it works

    The cleanup is identical to the Inline node: unload_all_models(), gc.collect(), torch.cuda.empty_cache(), ipc_collect(), synchronize(), with the allocated/reserved totals printed to the console. The difference is the trigger mechanism.

    There's one required input, purge_on_start (default true) - the tooltip calls it what it is: enable/disable the purge. Turn it off and the node logs "[VRAMPurge] Skipped (disabled)" and still passes its dummy outputs through.

    The outputs are the clever part: trigger_text (an empty STRING) and trigger_int (an INT, 0). They're not carrying data - they exist to force execution order. ComfyUI runs nodes in dependency order, so if you wire trigger_text into any STRING input on your first real node, the purge has to finish before that node starts. The comment in the source is explicit about it: the wired-in value doesn't matter, because ComfyUI resolves the real input anyway - the wire is pure scheduling.

    How to wire it

    The simplest pattern: connect the trigger_text output to a STRING input on your workflow's first node, or - the author's suggested route - into a Reroute node, then onward. The node never has to touch real data; it just has to be upstream of everything else. Since the outputs are typed STRING and INT, they fit most node inputs without needing converters.

    Install

    Pack-level, nothing special:

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

    Restart ComfyUI. No model downloads, no llama-cpp-python or transformers dependency - this one works even when the rest of the pack's backends don't load.

    Common issues

    • Nothing purges - check purge_on_start; it's the only thing that can switch the node off.
    • Purge isn't actually first - if you wired the trigger but a node still runs before it, you're probably feeding the trigger into something that isn't upstream of everything. Wire it into your first node.
    • "This input isn't used" - expected. The trigger value is a scheduling token, not data. That's the whole point.
    CategoryVLMPrompt

    Inputs (1)

    NameTypeDefaultDescription
    purge_on_startBOOLEANtrueEnable/disable the purge

    Outputs (2)

    NameTypeDescription
    trigger_textSTRING
    trigger_intINT