llama.cpp
Get a working, tuned and updatable llama-server (OpenAI- and Anthropic-compatible) for GGUF models on the user's hardware, and keep it healthy.
Scope: this one product: install, serve, tune, scale out (RPC), update, troubleshoot. Choosing between engines belongs to choosing-inference-engine.
Work through the steps in order. Load a reference only when a step names it. Flags below were verified on master build b11556 and the v0.6.0 release (2026-10-11). Builds move several times a day: confirm with llama-server --help on the installed binary.
Discover first
Read-only; nothing here prints secrets.
# Installed binaries and build number (bNNNN)
command -v llama-server llama-cli llama-bench llama-quantize llama 2>/dev/null
llama-server --version 2>&1 | head -3
# Backends and devices the binary can see
llama-server --list-devices 2>&1 | head -20
# Hardware
uname -sm; nvidia-smi -L 2>/dev/null; rocminfo 2>/dev/null | grep -m3 gfx; vulkaninfo --summary 2>/dev/null | grep -m3 deviceName
sysctl -n machdep.cpu.brand_string hw.memsize 2>/dev/null; free -g 2>/dev/null | head -2
# Already running?
ss -ltnp 2>/dev/null | grep -E ':(9931|8080)\b'; curl -s http://127.0.0.1:9931/health
# Model cache used by -hf
llama-server --cache-list 2>&1 | head
Decision flow
- No binary: pick the install route for the platform in
references/install.md(brew, winget, release archive, Docker image, or CMake build). Prefer a prebuilt package; build from source only for an unsupported backend or arch. - Apple silicon: Metal is on by default,
references/combos/apple-metal.md. AMD Ryzen AI Max (Strix Halo):references/combos/strix-halo-vulkan.md. NVIDIA DGX Spark/GB10 and other arm64 CUDA:references/install.md(Dockerserver-cuda13). - Model choice: pick a GGUF and quant with
references/models-and-formats.md; use-hf <user>/<repo>[:quant]to download. - Several models or swap-on-demand: built-in router mode, or llama-swap in front (
references/combos/llama-swap-router.md). Never use both to swap the same models. - Does not fit in memory or too slow:
references/performance-tuning.md(fit, KV types, MoE offload, batch sizes), thenreferences/parallelism-multinode.md(multi-GPU, RPC). - Tools, reasoning, JSON, vision, embeddings, rerank, speculative decoding:
references/features.md. - Failing:
references/troubleshooting.md.
Rules
- Ask before changing the system. Installs, services, firewall rules,
--host 0.0.0.0and compiling on a host that is serving need approval and an undo path. - Secrets never touch output. Use
--api-key-file(a0600file) orLLAMA_API_KEY, andHF_TOKENfrom the environment.--api-key KEYshows inps. - Always pass
--hostand--portexplicitly. The default port is 9931 on master (since b11521); v0.6.0 and older used 8080./healthis public, so it proves nothing about auth. - Loopback by default. Bind
127.0.0.1unless a gateway or reverse proxy (seellm-gateway) fronts it.--agent,--tools,--ui-mcp-proxy,--mcp-servers-*are experimental and unsafe on untrusted networks. The RPC server is unauthenticated: private links only. - Pin what you run. Record the build (
bNNNN) or image digest; tags likeserver-cuda13move with every build. - Smoke-test after every update:
/health, one chat completion, one tool call, one reasoning request. Templates and parsers change often. - Verify upstream. Flags and defaults change;
llama-server --helpis the authority for the installed binary. Do not copy flags from older blog posts (for example--draft-maxwas removed in favour of--spec-draft-n-max).
Workflows
- Install ->
references/install.md - First serve and flags ->
references/serve-config.md; run as a service withtemplates/llama-server.service,templates/llama-server.launchd.plistortemplates/docker-compose.yml - Choose model, quant, convert or quantize ->
references/models-and-formats.md - Tune speed and memory ->
references/performance-tuning.md; measure withllama-bench -m model.gguf -ngl 99 -fa on(engine only) orscripts/bench.sh(end-to-end HTTP) - Features: tools, reasoning, schema, vision, embeddings, speculative ->
references/features.md - API clients ->
references/api.md; gateways, UIs, Kubernetes ->references/integrations.md - Multi-GPU and RPC ->
references/parallelism-multinode.md - Metrics and logs ->
references/observability.md - Update ->
references/updating.md - Verify:
curl -s http://127.0.0.1:PORT/healthreturns 200,/v1/modelslists the alias, a chat completion returns text, and the startup log shows the expected backend (ggml_cuda_init,ggml_vulkan, Metal) with layers offloaded.
Minimal serve
llama-server -hf ggml-org/gemma-3-4b-it-GGUF:Q4_K_M -c 32768 -ngl all -fa on \
--host 127.0.0.1 --port 9931 -a local-model --api-key-file ~/.config/llama-server/keys
curl -s http://127.0.0.1:9931/health
Docker (NVIDIA, CUDA 13, amd64 and arm64):
docker run --rm --gpus all -p 127.0.0.1:8081:8080 -v /srv/models/gguf:/models:ro \
ghcr.io/ggml-org/llama.cpp:server-cuda13 -m /models/model-Q4_K_M.gguf -a small \
-c 32768 -ngl all -fa on -np 4 --host 0.0.0.0 --port 8080
Reference index
references/install.md: Homebrew, winget, conda, Nix, llama.app installer, release archives, Docker images, CMake builds per backend, aarch64/Blackwell/DGX Spark.references/serve-config.md: llama-server flags,LLAMA_ARG_*env vars, router mode and presets, auth, TLS, services.references/models-and-formats.md: GGUF, quant types,-hf, conversion,llama-quantize, imatrix, perplexity/KLD, LoRA.references/parallelism-multinode.md: split modes, tensor split, MoE CPU offload, RPC server across hosts.references/features.md:--jinjatools, reasoning, grammars and JSON schema, multimodal, embeddings and rerank, speculative decoding, slots, prompt cache.references/api.md: endpoints and request examples (OpenAI, Anthropic, native).references/performance-tuning.md: fit, context and slots, KV cache types, batch sizes, per-backend env vars, benchmarking.references/integrations.md: llama-swap, LiteLLM, OpenAI clients, Web UI, Kubernetes, editors.references/observability.md:/metrics,/props,/slots, logs.references/updating.md: update paths per install route, version pinning, rollback, smoke tests.references/troubleshooting.md: symptoms and fixes.references/combos/apple-metal.md,references/combos/strix-halo-vulkan.md,references/combos/llama-swap-router.md: verified combinations.templates/: systemd unit, launchd plist, docker-compose, Kubernetes manifest, router preset INI.scripts/bench.sh: end-to-end HTTP benchmark (shared canonical copy).
Companion skills
choosing-inference-engine: llama.cpp versus vLLM, SGLang, TensorRT-LLM. Install:npx skills add ScaleDockHQ/llm-skills --skill choosing-inference-engine.model-quantization: GGUF versus AWQ/GPTQ/FP8 decisions. Install:npx skills add ScaleDockHQ/llm-skills --skill model-quantization.llm-gateway: LiteLLM or another gateway in front ofllama-server. Install:npx skills add ScaleDockHQ/llm-skills --skill llm-gateway.local-llms: laptop and desktop workflow (llama.cpp, Ollama, LM Studio). Install:npx skills add ScaleDockHQ/llm-skills --skill local-llms.self-hosted-llms: running engines on owned GPU servers. Install:npx skills add ScaleDockHQ/llm-skills --skill self-hosted-llms.llama-swap: model swapping proxy (planned). Install:npx skills add ScaleDockHQ/llm-skills --skill llama-swap.nvidia-dgx-sparkandamd-strix-halo: platform notes (planned). Install:npx skills add ScaleDockHQ/llm-skills --skill nvidia-dgx-spark.speculative-decodingandmulti-node-inference: cross-engine techniques (planned). Install:npx skills add ScaleDockHQ/llm-skills --skill speculative-decoding.ollama,lm-studio,vllm,tailscale,cloudflare-tunnel: neighbours. Install withnpx skills add ScaleDockHQ/llm-skills --skill <name>.