Nodes/CC Llama Vision/CC Llama Server Unload (free VRAM)
ComfyUI Node

CC Llama Server Unload (free VRAM)

Free your VRAM between captioning and generating — without the OOM roulette

By cicalooo·Created 2 months ago·Updated 2 months ago· 1
CC Llama Server Unload (free VRAM)
    • trigger
    trigger
    targetall_servers
    also_free_comfyui_vramtrue
    port8080

    Here's the problem this node exists to solve, and you've probably hit it if you've ever run a local LLM and a diffusion model in the same graph. llama-server is an external subprocess - ComfyUI's own model manager has no idea it exists and no idea it's holding a few gigabytes of VRAM. So you caption your image with CC Llama Vision, then a big checkpoint tries to load downstream... and you OOM on a card that should have been plenty.

    CC Llama Server Unload is the handoff. You chain it between the caption node and whatever consumes its text, and it guarantees the llama-server process is dead before the diffusion model loads - no timers, no manual killing, no guesswork about when.

    How it works

    The clever bit is that it uses ComfyUI's own execution order as the mechanism. ComfyUI runs nodes in dependency order, so if you feed the node's output into the thing that needs the VRAM, the node is forced to run first. Its required trigger input takes an upstream string - typically the caption output from CC Llama Vision - and its trigger output passes that string straight through, so the data flow is unbroken:

    CC Llama Vision (caption) → CC Llama Server Unload → CLIPTextEncode.text → KSampler
    

    When it runs, it kills every tracked llama-server process (or just the one on your chosen port), and if also_free_comfyui_vram is on - it is by default - it also asks ComfyUI to unload its own models and empty its VRAM cache. What comes out the other side is the same caption string, untouched. The node is just a well-placed cleanup stop on the way to your sampler.

    Inputs and output

    Only four inputs, and you'll mostly leave three of them alone:

    • trigger - the required string to chain from. Wire the caption (or any upstream string) in here.
    • target - all_servers (default) or specific_port. You'll pick specific_port only if you're running multiple tracked servers and want to keep one alive.
    • also_free_comfyui_vram - default true. Unloads ComfyUI's own loaded models and empties the cache after killing llama-server. This is the "clean everything" option, and it's worth keeping on in a caption→generate workflow.
    • port - used only when target is specific_port; defaults to 8080, the same default CC Llama Vision uses.

    The single output, trigger, is the caption string passed through - plug it into CLIPTextEncode's text input or wherever the caption was heading.

    When you actually need it

    Not every workflow does. If keep_server_alive is off on the main node, CC Llama Vision already kills its temporary server after each run - there's nothing left to unload, and this node will cheerfully print "No matching llama-server was running" and move on. You want the Unload node when:

    • you've turned keep_server_alive on for speed and your pipeline has a big generation step later,
    • you're running a long mixed workflow and want a guaranteed cleanup point,
    • you'd rather be explicit about VRAM handoff than trust idle timeouts.

    How to install it

    It ships with the pack - same install as the rest: ComfyUI Manager, search "CC Llama Vision", or

    cd ComfyUI/custom_nodes
    git clone https://github.com/doggeddalle/ComfyUI-cc_llama_vision
    

    then restart. No extra dependencies beyond what the pack already needs (llama-server on PATH plus your GGUF model and mmproj).

    Gotchas

    The failure mode to watch is wiring. If you don't actually chain this node's output into the consumer that needs the VRAM, it still runs (ComfyUI will execute it), but the guarantee vanishes - the node can't enforce ordering it isn't part of. Feed its trigger output into the image-generation path, not past it. And don't expect it to know about servers this pack didn't start: it only kills servers in its own process registry, so a llama-server you launched by hand in a terminal is your problem, not its. One genuinely nice detail from the code: there's an exit hook so even if you never add this node, kept-alive servers get cleaned up when ComfyUI shuts down instead of being orphaned to hold your VRAM forever.

    Categoryllama.cpp

    Inputs (4)

    NameTypeDefaultDescription
    triggerSTRINGUpstream string output to chain from (e.g. the caption output) — guarantees this node runs before whatever consumes it, since ComfyUI executes in dependency order.
    targetCOMBOall_serversWhich server(s) to kill: every currently tracked llama-server process, or only the one on the specified port.
    also_free_comfyui_vramBOOLEANtrueAlso ask ComfyUI to unload its own loaded models and empty its VRAM cache after killing llama-server.
    portoptINT80801024–65535Port of the specific llama-server to kill, used only when 'target' is 'specific_port'.

    Outputs (1)

    NameTypeDescription
    triggerSTRING