Nodes/FMJ-LLM/đŸ§č FMJ Unload All LLM
ComfyUI Node

đŸ§č FMJ Unload All LLM

FMJ Unload All LLM kicks Ollama out of memory on demand

By bulldog68·Created 10 months ago·Updated 3 months ago· 3
đŸ§č FMJ Unload All LLM
    • status
    ◄triggerfalseâ–ș

    Ollama is a polite house guest that never leaves. After it answers a prompt, it keeps the model sitting in memory for a while - this pack's own nodes use a 5-minute keep_alive by default - so if you bounce between an LLM call and a heavy generation on a card with limited VRAM, the two end up fighting over the same tens of GB. đŸ§č FMJ Unload All LLM is the "please leave" button.

    It's the smallest node in the FMJ-LLM pack, and it does exactly one thing well: it asks Ollama to unload every currently-loaded model. If that sounds mundane, try doing it by hand from the terminal sometime.

    How it works

    The mechanism is straight out of Ollama's own API docs, which is reassuring. When you trigger the node it:

    1. Calls GET /api/ps to list the models Ollama currently has loaded.
    2. For each one, sends POST /api/generate with keep_alive: 0.

    That keep_alive: 0 is Ollama's documented "unload this right now" flag (the opposite of -1, which pins a model in memory forever). Community threads on r/comfyui confirm the pain this solves - people hunting for ways to force Ollama to release VRAM after generation, either with an OLLAMA_KEEP_ALIVE=0 environment variable or per-call keep_alive: 0. This node is the per-call version, on demand and inside your graph.

    The inputs and outputs

    There's one input and one output, so this is a two-minute read:

    • trigger - a BOOLEAN that defaults to False. You have to flip it on for anything to happen. That's deliberate: it stops the node from firing on every queue run.
    • status - a STRING output telling you what happened: which models were unloaded, "no models loaded", or an error if Ollama couldn't be reached.

    Wire the status output to a text display or just read it in the node. There's nothing to connect upstream unless you want to trigger it programmatically - a Reroute or any boolean works.

    Installing it

    Same pack, same steps as the rest of FMJ-LLM: ComfyUI Manager → search "ComfyUI_FMJ_LLM", or cd ComfyUI/custom_nodes && git clone https://github.com/bulldog68/ComfyUI_FMJ_LLM, then restart ComfyUI. The only dependency is the ollama Python package, which Manager handles. You need the Ollama runtime installed and running, naturally.

    Gotchas

    • The URL is hardcoded. Unlike the pack's other nodes, FMJ Unload All LLM has no ollama_url field - it always talks to http://localhost:11434. If your Ollama runs on another machine, this node can't see it.
    • Trigger defaults to False, and that trips people up constantly. You flip it, run, and read the status string. Nothing happens silently otherwise.
    • If no model is loaded, it just tells you so. Not an error - a feature.

    Reach for it before a long generation or before swapping in a big model, and you won't be watching your sampler OOM on a model Ollama still had parked in VRAM.

    Category🌀FMJ

    Inputs (1)

    NameTypeDefaultDescription
    triggerBOOLEANfalse—

    Outputs (1)

    NameTypeDescription
    statusSTRING—