1. Learn
  2. Run and serve it

llama.cpp server guide: run llama-server with the flags that matter

Install llama.cpp, download a model, and serve it with llama-server. The handful of flags that matter for GPU layers, context and parallel users.

Updated Oct 26, 2026 · RunItLocal.io

llama-server is llama.cpp's built-in server. One command loads a GGUF model, puts it on your GPU, and serves a chat page plus an OpenAI-compatible API at http://localhost:8080. It's what Ollama and LM Studio are built on, with every setting exposed. If you haven't picked a tool yet, read Ollama vs llama.cpp vs LM Studio first.

Install it

On a Mac, Homebrew has it:

brew install llama.cpp

On Windows, winget install llama.cpp works, or download a prebuilt release from the llama.cpp GitHub page. Pick the CUDA build for NVIDIA cards and the Vulkan build for AMD or Intel.

On Linux with an NVIDIA card, building it yourself is the usual route. You need the CUDA toolkit, CMake and a compiler:

cmake -B build -DGGML_CUDA=ON && cmake --build build --config Release -j

The programs end up in build/bin/. Building for your own card is also how you keep older GPUs like the Tesla P100 working when prebuilt packages drop them.

Start a server

llama-server -hf unsloth/Qwen3-8B-GGUF:Q4_K_M -ngl 99 -c 16384 --jinja

That downloads Qwen3 8B at Q4_K_M from Hugging Face, caches it, and starts serving. Open http://localhost:8080 for the built-in chat page. If you already have a GGUF file, use -m path/to/model.gguf instead of -hf.

The flags that matter

FlagWhat it doesTypical value
-m / -hfLocal file, or a Hugging Face repo with an optional :QUANT tag
-nglHow many layers go on the GPU99 means all of them
-cContext length in tokens8192 to 32768
--hostWhich address to listen on127.0.0.1 (default) or 0.0.0.0
--portPort8080 (default)
-npParallel slots, for several users at once1 to 4
--api-keyRequire a key on every requesta long random string
--jinjaUse the model's own chat templateon for tool calling

A few notes on those:

  • -ngl is your speed dial. All layers on the GPU is fastest. If the model doesn't fit, lower it until it loads; the rest runs on the CPU, and speed falls a lot. See CPU offloading explained.
  • -c costs memory. Context lives in the KV cache, next to the model. Doubling it can add gigabytes. See how much VRAM you need.
  • -np splits the context. With -c 32768 -np 4, each of the four slots gets 8,192 tokens. Raise -c when you raise -np.
  • --host 0.0.0.0 opens it to your network. Only do that with --api-key set, and never forward the port to the internet. See securing your local AI server.

Use the API

Any app that speaks the OpenAI API can use it. Point it at http://localhost:8080/v1:

curl http://localhost:8080/v1/chat/completions -H "Content-Type: application/json" -d '{"messages":[{"role":"user","content":"Say hello in five words."}]}'

You don't need a model name, because the server has one model loaded. http://localhost:8080/health answers when it's ready, which is handy for scripts and Docker health checks.

Two GPUs

If llama.cpp sees two cards, it splits the model's layers across them automatically. Add -ts 1,1 to set the split ratio by hand, for example -ts 3,1 if one card has more free memory. A layer split pools memory but runs at about one card's speed, because the cards take turns. That's still the cheapest way to fit a 30B model: on our rack, two Tesla P100s run Qwen3.6-35B-A3B at 53 tok/s, and two RTX A4500s at 110 tok/s.

What to expect

Speed with everything on the GPU is set by memory bandwidth. Here's what our calculator estimates for two P100s, 32 GB in total, the "Best value" build on the builds page:

Tesla P100, 32 GB · estimated with our calculator · full page

  • Qwen3 4BQuick everyday chat and summaries
    ~160 tok/s
    Runs greatqwen3:4b
  • Qwen3 8BA solid all-rounder for chat and writing
    ~77 tok/s
    Runs greatqwen3:8b
  • Gemma 3 12BReads images as well as text
    ~50 tok/s
    Runs greatgemma3:12b
  • Qwen3 14BNoticeably smarter at reasoning and code
    ~43 tok/s
    Runs greatqwen3:14b
  • gpt-oss 20BOpenAI's open model. Fast, strong reasoning
    ~130 tok/s
    Runs greatgpt-oss:20b
  • Gemma 3 27BGoogle's best open model for its size
    ~24 tok/s
    Usablegemma3:27b
  • Qwen3 30B-A3B30B smarts at small-model speed
    ~130 tok/s
    Runs greatqwen3:30b
  • Qwen3 32BStrong coding and long answers
    ~20 tok/s
    Usableqwen3:32b
  • Llama 3.3 70BClose to the big cloud models
    needs 45 GB
    Too bigllama3.3:70b
  • gpt-oss 120BOpenAI's largest open model
    needs 67 GB
    Too biggpt-oss:120b
  • Qwen3 235B-A22BAlibaba's flagship open model, for multi-GPU rigs
    needs 144 GB
    Too bigqwen3:235b
  • DeepSeek R1 671BThe full DeepSeek R1, for the biggest rigs
    needs 406 GB
    Too bigdeepseek-r1:671b

Where to go next