Nodes/ComfyUI-ollama_killer/Ollama Process Killer
ComfyUI Node

Ollama Process Killer

Kill the Ollama process hogging your VRAM — politely first, then with force

By theshubzworld·Created 2 years ago·Updated 9 months ago· 3
Ollama Process Killer
    • status
    • output_text
    text
    triggerfalse
    force_killfalse

    So you've got a workflow where an Ollama model writes your prompt, and then the KSampler needs the whole GPU to itself. Except it doesn't have it, because Ollama is still sitting on a few gigs of VRAM. That's the problem this node exists for: it finds the running Ollama process and terminates it, on your schedule, from inside the graph. The name oversells the violence - it's really a polite shutdown that escalates to force-kill only if asked.

    Why this is even a thing. Ollama keeps models loaded in VRAM after a request finishes - the default keep_alive is 5 minutes, so an 8GB LLM can sit pinned on your card long after you've moved on to generating. If you run Ollama and ComfyUI on the same GPU, that's real memory you can't use. ComfyUI's own VRAM management gets most of the attention in the ecosystem docs, but it can't reclaim memory some other process is holding. Something has to evict Ollama, and this node is a way to make that eviction part of the workflow itself.

    How it works. Under the hood it's psutil, nothing fancy. When trigger flips to true, the node scans running processes and matches the name for your platform - ollama.exe on Windows, ollama on macOS and Linux. For each match it calls terminate() (a graceful SIGTERM) and waits up to 5 seconds. If the process doesn't die in time and you've enabled force_kill, it calls kill(). It even catches the race where the process already died on its own and reports it as a win rather than an error. The status string tells you exactly what happened, down to PIDs.

    The inputs that matter. Three, and you really only touch two:

    • text - required, any string. This is a passthrough; the node doesn't read or modify it, it just hands it back so you can inline the node in a chain without breaking the text flow.
    • trigger - a boolean toggle, default off ("Idle"). Flip it to "Kill Process" to run the kill. Off means nothing happens except the passthrough.
    • force_kill - optional, false/true string. Turn this on if a graceful terminate is timing out.

    Outputs. status is the human-readable report ("Successfully terminated 2 of 2 process(es)." plus per-PID detail) - wire it into a ShowText node if you want to see it. output_text is your original input, unchanged. The node is marked as an output node, so it executes as a terminal step in your graph.

    Installing. Either grab it in ComfyUI Manager (search "OllamaKiller"), or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/theshubzworld/ComfyUI-ollama_killer.git
    

    Then restart ComfyUI. One gotcha the README won't tell you: this pack declares no dependencies at all - no requirements.txt, no [project.dependencies]. It imports psutil anyway and trusts it to be there. Most ComfyUI installs have psutil transitively, but if the node fails to load with a ModuleNotFoundError: psutil, that's why. pip install psutil into your ComfyUI environment fixes it.

    Where people get burned. If the process won't die, enable force_kill - some Ollama child processes ignore SIGTERM. If you see "No ollama processes found" while Ollama is clearly running, it's probably running under a different binary name than the one the node matches (or you're actually using LM Studio, which this node won't touch). And on macOS/Linux, process access can be denied if the service runs under another user.

    Honestly, before you build this into every workflow, know the alternative: set OLLAMA_KEEP_ALIVE=0 and Ollama unloads each model the moment a request finishes - no killing required, and it's the fix most people land on. This node is for when you want that eviction to be explicit, immediate, and part of the graph - which, for a shared-GPU setup, is a genuinely clean answer.

    Categoryutils

    Inputs (3)

    NameTypeDefaultDescription
    textSTRING
    triggerBOOLEANfalse
    force_killoptCOMBOfalse2 options: false, true

    Outputs (2)

    NameTypeDescription
    statusSTRING
    output_textSTRING