MD: LLM VRAM Manager
Running Ollama and ComfyUI on the same GPU? This node frees the VRAM first
- pass_through
- image_in
- latent_in
- pass_through
- status
- seed_out
- image_out
- latent_out
If you've ever had ComfyUI choke with an out-of-memory error the moment you queued a render, and then realized your local LLM was still squatting on 8GB of VRAM, this is the node you've been looking for. LLMVRAMManager sits in your graph, and right before your sampler runs, it tells Ollama, llama-swap, or LM Studio to give the memory back. It's part of MD Nodes, the MDMAchine pack that grew out of the ACE-Step audio scene, and it's the polite version of "close every other tab before you start."
The trick is that ComfyUI is lazy. Nodes only execute when something downstream actually needs their output, so a node that just "does a thing" won't run at all unless you wire it into the flow. That's what the whole pass-through design is about: you run your latent, image, or seed through this node so ComfyUI is forced to execute it at the right point in the graph.
What it does
The action dropdown is the whole node. Nine options split into two families:
- API unloads (graceful) - Unload Ollama Models, Unload llama-swap Models, or both. These call the server's unload endpoint, let the model release its weights, and are what you should try first.
- Force stops (blunt) - Stop Ollama Process, Stop LM Studio Process, or both. On Windows it's
taskkill; on Linux it'spkillorsystemctl stop. These are abrupt and guaranteed to free memory, but they kill the server too, so you'll be waiting for it to restart if you need it again this session.
There's also a master trigger boolean. Set it to True and the action fires; set it to False and the node becomes a harmless pass-through so you can A/B test without rewiring anything.
The unload logic is real code, not a wrapper around a dream: it talks to Ollama's and llama-swap's HTTP APIs, and it reads MD_OLLAMA_HOST and MD_LLAMA_SWAP_HOST environment variables if your servers aren't on the default localhost ports (llama-swap inside Docker is the common case). The LM Studio SDK unload is present in the list but marked [DISABLED] - a placeholder that does nothing yet, so don't reach for it.
The inputs and outputs that matter
You mostly set action and trigger, then thread one of the pass-throughs. In the optional pile: pass_through (any type), seed_in, image_in, latent_in, and debug_mode for console output. Outputs mirror them - pass_through, status, seed_out, image_out, latent_out. status is the one worth looking at; it tells you what unloaded and whether it worked. This is an output node, so expect it to act as a terminal-ish gate rather than a mid-stream component.
Installing it
The node ships in MD Nodes, so install the whole pack:
cd path/to/ComfyUI/custom_nodes
git clone https://github.com/MDMAchine/ComfyUI_MD_Nodes.git
cd ComfyUI_MD_Nodes
pip install -r requirements.txt
Or in ComfyUI Manager, search for MD Nodes and click Install, then restart ComfyUI. Fair warning: that requirements.txt is heavy - the pack drags in the audio stack (librosa, soundfile, pyloudnorm, pedalboard), matplotlib, pynvml, and Ollama/LM Studio client libraries even if all you wanted was this one node. It's a known cost of the pack.
Gotchas
Force-stopping Ollama on Linux may need elevated privileges depending on how it's running as a service, and killing the process mid-generation elsewhere is your problem, not the node's - this only touches the LLM side. The bigger conceptual trap is remembering why it ran: if you don't connect any pass-through, the node may never execute, because ComfyUI skips nodes nobody depends on. Wire something through it.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| action | COMBO | None (Do Nothing) | ACTION TO PERFORM • Purpose: Select the operation to free up LLM VRAM. • Options: API unloads (graceful) or Process Kills (forceful). • Trade-offs: Force stops are abrupt but guaranteed to clear memory. ⭐ Recommended: Try API methods first before resorting to force stops. |
| trigger | BOOLEAN | true | ENABLE ACTION TRIGGER • Purpose: Master switch for the node's destructive actions. • Options: True executes the action; False makes the node a passive pass-through. ⭐ Recommended: True. |
| pass_throughopt | * | PASS-THROUGH (Generic) • Purpose: Connect any generic data type here to enforce workflow execution order. | |
| seed_inopt | INT | 00–18446744073709550000 | PASS-THROUGH (Seed) • Purpose: Pass an integer/seed safely through the node to control execution order. |
| image_inopt | IMAGE | PASS-THROUGH (Image) • Purpose: Pass an image tensor safely through the node. | |
| latent_inopt | LATENT | PASS-THROUGH (Latent) • Purpose: Pass a latent dictionary safely through the node. | |
| debug_modeopt | COMBO | 0 - Silent | LOGGING VERBOSITY • Controls console output and System/IO profiling. |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| pass_through | * | — |
| status | STRING | — |
| seed_out | INT | — |
| image_out | IMAGE | — |
| latent_out | LATENT | — |