ApoStudio Unload Models
Kick your LLM out of VRAM when the chat is over — LM Studio gets evicted by CLI
- status
- trigger_out
When you run a chat LLM in ComfyUI, you're budgeting VRAM for two models at once - the LLM sitting in its server and the diffusion model waiting for its turn. LM Studio keeps the LLM resident in memory, so the first image gen after a chat run can stall or, worse, start thrashing. ApoStudio Unload Models is the cleanup step: a node that tells LM Studio to free everything the moment your workflow is done with it.
How it works. It shells out to LM Studio's CLI (lms.exe on Windows, lms elsewhere) and runs lms unload --all. That's the whole mechanism, and it's why the README is upfront about this being LM Studio-specific - every other ApoStudio node works with any OpenAI-compatible server, but this one literally speaks the lms command. Point it at Ollama and it just returns an error string.
Inputs and outputs. execute is a boolean toggle - Unload on Run / Skip. It defaults to on, and the Skip position is genuinely useful when you're iterating on a chat workflow and don't want the model evicted every run. trigger_in is the subtle bit: wiring Chat's response into it guarantees this node runs after Chat delivers its reply, since ComfyUI doesn't guarantee ordering between otherwise-unconnected branches. On the way out you get status (the CLI's result message, or a helpful ERROR: 'lms' not found if the CLI isn't installed) and trigger_out, which passes trigger_in straight through so you can keep the execution chain going into a Display.
Chat (response) ──► Unload (trigger_in) ──trigger_out──► Display
Install. The pack installs like its siblings - ComfyUI Manager (search "ApoStudio") or git clone https://github.com/apoloniart/ApoStudio into custom_nodes/, then pip install -r custom_nodes/ApoStudio/requirements.txt (just requests and Pillow). What you also need, separately, is the LM Studio CLI available on your PATH. That's a LM Studio install step, not a ComfyUI one.
Gotchas. If status comes back with an error about lms not being found, the CLI isn't on your PATH - that's the #1 issue, and it's environmental. If you're using a non-LM Studio server, skip this node entirely; it'll do nothing but print an error. And don't put it mid-pipeline: it's designed as an end-of-chain cleanup node, so place it after the chat branch finishes, not before a second Chat turn that still needs the model.
The name makes it sound fancy; it's a one-command wrapper with a well-placed toggle. But in a workflow where you chat and then generate, that one command is the difference between smooth next-gen and a memory swapfest.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| execute | BOOLEAN | true | — |
| trigger_inopt | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| status | STRING | — |
| trigger_out | STRING | — |