Nodes/ComfyUI llama.cpp Suite/Start llama.cpp Server
ComfyUI Node

Start llama.cpp Server

Start llama.cpp Server

By Setmaster·Created 8 months ago·Updated 2 months ago· 6
Start llama.cpp Server
    • server_url
    • success
    modelNo models found - add .gguf files to models/LLM/gguf/
    context_size4096
    gpu_layers
    main_gpu0
    port8080
    threads
    batch_size512
    flash_attentionfalse
    timeout60
    binary_path
    host127.0.0.1
    tensor_split
    no_mmapfalse
    flash_attention_modelegacy
    mmproj(auto)
    sleep_idle_seconds0
    api_key_file
    api_key_envLLAMACPP_API_KEY
    media_path
    fit_modeupstream default
    unload_comfy_models_before_startfalse
    extra_args

    This is the node everything else in the ComfyUI llama.cpp Suite hangs off. Nothing else in the pack works until this one has done its job: it finds your llama-server binary, launches it, loads a GGUF model into it, and only then hands you a server_url to feed into a prompt node. Think of it as a CheckpointLoader for language models, except the "checkpoint" is a whole separate process that keeps running.

    The design decision that defines the whole pack: the model lives in an external llama-server process, not inside ComfyUI's Python process. That's the opposite of the in-graph GGUF loaders other packs use, and it's deliberate. Because the LLM is a separate process, you can stop it, restart it, and free its VRAM without touching ComfyUI's own model cache - which matters when you want to hand the GPU back to a diffusion model after the LLM writes your prompt.

    How it works

    Start llama.cpp Server resolves the executable in a specific order: the binary_path input, then the LLAMA_SERVER_BINARY environment variable, then llama-server on your PATH. It probes the binary with --version and --help, records its identity, and refuses to launch if you ask for an option the binary doesn't support. It waits for the server to be actually ready (default 60-second timeout) before reporting success.

    The node is idempotent: re-queue the same config and it won't restart anything. Change the model or an effective setting and it does a coordinated restart. If a replacement preflight fails, it leaves a healthy existing server alone rather than tearing it down.

    The inputs that matter

    • model - the GGUF file to serve, picked from ComfyUI/models/LLM/gguf/. If the dropdown says "No models found", that folder is empty or misplaced.
    • context_size - max context in tokens (default 4096). This directly sets how much VRAM the KV cache eats; too high and the server won't fit.
    • gpu_layers - empty preserves the legacy "offload everything" behavior; you can also type auto, all, or a number of layers to offload.
    • port - defaults to 8080. If it's taken by another listener, the pack refuses to adopt it and you'll need to change it.
    • mmproj - for vision models, the matching multimodal projector. (auto) leaves discovery to llama-server, which isn't a promise it'll find your projector.

    Wire server_url into a prompt node's server_url input (or just leave that empty and it finds the managed server), and success anywhere you need the workflow to wait for startup.

    Installing it

    Install the pack once, then install llama.cpp separately - they're independent. From ComfyUI Manager, search "comfyui-llamacpp", or:

    cd ComfyUI/custom_nodes
    git clone --branch master https://github.com/Setmaster/comfyui-llamacpp.git
    cd comfyui-llamacpp
    python -m pip install -r requirements.txt   # use your ComfyUI Python
    

    Restart ComfyUI. Then grab a current llama-server build from the llama.cpp releases, build it from source, or use your package manager, and make sure llama-server is on PATH (or set LLAMA_SERVER_BINARY). On Windows, deploy the complete release archive into a clean directory - the CUDA builds need their companion DLLs and a separate CUDA runtime archive; swapping in only llama-server.exe breaks things. Finally, drop a .gguf file into models/LLM/gguf/.

    Common issues

    • "llama-server was not found" - it's not on PATH in the environment that launches ComfyUI. Verify with llama-server --version, then set LLAMA_SERVER_BINARY to the full path.
    • Server starts and exits - usually a model architecture the build doesn't support, not enough VRAM/RAM, or a mismatched projector. Drop context_size, use a smaller quant, or fewer gpu_layers.
    • Port already in use - the pack won't kill a random process just because it's named llama-server. Change the port or stop the other listener.

    The GPU handoff tip: if you're doing LLM-writes-prompt-then-diffusion, set unload_comfy_models_before_start to evict Comfy's managed models before the LLM allocates memory. When the LLM is done, Comfy's native Unload Models action stops this pack's owned server and returns the VRAM.

    CategoryLlamaCpp

    Inputs (22)

    NameTypeDefaultDescription
    modelCOMBONo models found - add .gguf files to models/LLM/gguf/GGUF model file to serve from a configured Comfy model folder.
    context_sizeINT40960–1048576Maximum context size in tokens. 0 lets llama-server choose.
    gpu_layersSTRINGLayers to offload to GPU. Empty preserves legacy all-layers behavior; auto, all, or a number are also accepted.
    main_gpuINT00–31Primary GPU index used by llama-server.
    portoptINT80801–65535TCP port for the owned llama-server.
    threadsoptSTRINGCPU generation threads. Empty lets llama-server choose.
    batch_sizeoptINT5121–65536Logical prompt-processing batch size.
    flash_attentionoptBOOLEANfalseLegacy flash-attention toggle. Prefer flash_attention_mode for new workflows.
    timeoutoptSTRING60Startup readiness deadline in seconds. Empty has no limit.
    binary_pathoptSTRINGExplicit llama-server executable. Empty uses LLAMA_SERVER_BINARY, then PATH.
    hostoptSTRING127.0.0.1Network interface address to bind. Loopback is safest.
    tensor_splitoptSTRINGPer-GPU model proportions, for example 3,1.
    no_mmapoptBOOLEANfalseDisable memory-mapped model loading.
    flash_attention_modeoptCOMBOlegacyModern flash-attention mode. Legacy preserves the released flash_attention widget behavior.
    mmprojoptCOMBO(auto)Matching multimodal projector for local VLMs. (auto) leaves projector discovery to llama-server.
    sleep_idle_secondsoptINT00–864000 disables idle sleep. Positive values release model VRAM while idle.
    api_key_fileoptSTRINGPath to a llama-server API key file, one key per line.
    api_key_envoptSTRINGLLAMACPP_API_KEYEnvironment variable containing the matching client key. The secret is not serialized.
    media_pathoptSTRINGDirectory allowed for llama-server file:// media inputs.
    fit_modeoptCOMBOupstream defaultControl whether llama-server adjusts unset arguments to fit device memory.
    unload_comfy_models_before_startoptBOOLEANfalseEvict Comfy-managed models before llama-server allocates GPU memory.
    extra_argsoptSTRINGAdvanced llama-server arguments. No shell is used.

    Outputs (2)

    NameTypeDescription
    server_urlSTRINGURL of the running owned llama-server.
    successBOOLEANWhether server startup reached its ready state.