To clear VRAM in a running ComfyUI, send a POST request to its /free endpoint with unload_models and free_memory set to true. Restarting the ComfyUI process also frees everything.
The /free endpoint
ComfyUI's server defines POST /free and reads two flags from the JSON body: unload_models and free_memory. Between jobs, the queue worker then unloads all models, and with free_memory also resets the executor and garbage-collects.
curl -X POST http://127.0.0.1:8188/free \
-H "Content-Type: application/json" \
-d '{"unload_models": true, "free_memory": true}'
Change the host and port if you run ComfyUI elsewhere (the default is 8188, see the ComfyUI default port). The request takes effect when the queue worker next checks its flags, so it is applied right after the running job finishes.
Keep memory from filling in the first place
--disable-smart-memorymakes ComfyUI offload to RAM instead of keeping models in VRAM.--highvramis the opposite: it keeps models on the GPU after use.
If the real problem is an error, read how to fix a ComfyUI out of memory error. For the rest of the install and node side, see the ComfyUI custom node install guide.
Sources
- ComfyUI server.py (/free route). github.com
- ComfyUI main.py (queue flag handling). github.com
- ComfyUI cli_args.py. github.com