llama.cpp runs a GGUF model on your own machine as a terminal chat or as an OpenAI-compatible server, and the project’s CLI documentation describes llama cli as its terminal front end for chat and experiments. We ran steps 1, 2, 5, 7 and 8 below on 12 November 2026 against v0.9.0, the release GitHub published on 4 November 2026 and marked Latest (the previous edition of this page named v0.7.0, which was two releases behind on 12 November 2026). That release holds only a pointer file, and the runnable binary is build b12110. A prebuilt 23 MB archive of that build ran a 0.5B model at 50.28 tokens/s of generation on 4 CPU threads, with no compile.


Don't miss new tech stories on Google
Add Tech Insider once in the Google app and our stories appear in your news suggestions.
v0.9.0 is a pointer file and the binary is build b12110: steps 1 and 2
The v0.9.0 release carries a single file, nightly-tag.txt, that names the build to run, and it reads b12110, so the archive comes from the b12110 build release and not from the v0.9.0 page. Before it came v0.8.0 on 28 October 2026 and v0.7.0 on 15 October 2026. The releases page also lists b12318, published on 12 November 2026, so newer builds than the one we ran exist. Pinning b12110 gives you the exact binary behind every result below.
Step 1 is the download. Save this as get-llama.sh and run sh get-llama.sh. The set -e line stops the script at the first failed command, and -f makes curl fail on an HTTP error instead of saving an error page as the archive.
#!/bin/sh
set -e
BUILD=b12110
mkdir -p llama-lab
cd llama-lab
curl -fsSL "https://github.com/ggml-org/llama.cpp/releases/download/$BUILD/llama-$BUILD-bin-ubuntu-x64.tar.gz" -o llama.tgz
tar xzf llama.tgz
"./llama-$BUILD/llama-cli" --version
Step 2 is the version check, which the last line of the script runs. To see the pointer yourself, fetch https://github.com/ggml-org/llama.cpp/releases/download/v0.9.0/nightly-tag.txt with curl; it prints b12110. Our lab piped the same download straight into tar xz and got this:
$ llama-b12110/llama-cli --version
version: 0.9.0-dev (build 12110, commit cd959bae9)
built with GNU 11.4.0 for Linux x86_64
The archive is 23,051,958 bytes and unpacks to 56 MB. It ships one CPU binary set with per-microarchitecture ggml CPU backends (haswell, skylakex, zen4 and others), so nothing needs compiling to run on CPU. Everything measured on this page ran on Linux x86_64 (kernel 5.15.0-171-generic) with 4 Intel vCPUs, 7 GB of RAM and no GPU.
| Route | What the project documents | Pick it when |
|---|---|---|
| Prebuilt archive | Release assets for Ubuntu x64 CPU (the one above), Vulkan, CUDA 12 and CUDA 13 | You want a pinned binary and no toolchain |
| Installer | An installer for macOS and Linux | You want one command on those systems |
| Homebrew | brew install llama.cpp | macOS or Linux with Homebrew already in use |
| WinGet | winget install llama.cpp, updated automatically with new releases | Windows |
| Nix | Listed in the install docs | You manage machines with Nix |
| Docker | Official images at ghcr.io/ggml-org/llama.cpp | You deploy in containers |
| Llama app | A desktop app built on llama.cpp for downloading and chatting with models in a few clicks | You do not want a terminal |
| Source build | CMake, covered in step 3 | Your GPU backend has no prebuilt archive, or you change the code |
Older guides break on names. Pull request #7809 renamed main to llama-cli and server to llama-server in 2024. A guide that tells you to run ./main is out of date, and the Transformers documentation names convert_hf_to_gguf.py as the conversion script. The project README shows the space form, llama cli -hf and llama serve -hf; the archive we ran contains the hyphenated llama-cli and llama-server, and those are the binaries this page uses.
Related Tech Insider guides: the Ollama tutorial and the RTX Spark walkthrough.
Step 3, only if you need a GPU: the CMake flag for each backend, or a prebuilt CUDA or Vulkan archive
The b12110 release page, checked on 12 November 2026, lists prebuilt archives for Ubuntu x64 with Vulkan, Ubuntu arm64 with Vulkan, Ubuntu x64 with CUDA 12 (CUDA 12.8 libraries) and Ubuntu x64 with CUDA 13 (CUDA 13.4 libraries). On those platforms you can repeat step 1 with the matching asset and skip the compile. Build from source when your backend has no archive. The flags below come from the project’s build documentation; our lab ran only the CPU archive.
| Hardware | Backend | CMake flag | Note |
|---|---|---|---|
| NVIDIA GPU | CUDA | -DGGML_CUDA=ON | Needs the CUDA Toolkit installed |
| AMD GPU | HIP | -DGGML_HIP=ON | Set -DGPU_TARGETS to your gfx architecture |
| Any GPU | Vulkan | -DGGML_VULKAN=ON | Cross-vendor |
| Intel GPU | SYCL | See the SYCL section of build.md | Follow that document’s own steps |
| Apple Silicon | Metal | None | On by default on macOS; -DGGML_METAL=OFF disables it |
On Ubuntu or Debian, install the build tools first, then clone, configure and build. git log -1 --oneline shows which commit you cloned, and ls build/bin/ lists the result.
sudo apt update
sudo apt install -y build-essential cmake git curl python3 python3-pip
git clone --depth 1 https://github.com/ggml-org/llama.cpp
cd llama.cpp
git log -1 --oneline
cmake -S . -B build -DGGML_CUDA=ON
cmake --build build --config Release -j
ls build/bin/
Swap the flag for your backend; the binaries land in build/bin. Look there for llama-cli, llama-server, llama-completion, llama-bench and llama-quantize, the tools this page uses.
Step 4: a 491.4 MB model file used 587 MB of RAM, so size the model from the file
llama.cpp runs models stored as GGUF, a single file that packages the weights, tokenizer and metadata. A model in another format, for example a Transformers checkpoint, has to be converted first, which step 10 covers.
Our model was Qwen2.5-0.5B-Instruct at Q4_K_M, a 491,400,032 byte file (491.4 MB). With llama-server loaded at a 2048 token context, resident memory was 587 MB on all 3 runs. Dividing 587 by 491.4 gives 1.19, so the process held about 96 MB more than the file (587 minus 491.4 is 95.6). That ratio is a calculation from two lab numbers for one small model at one context length. NVIDIA’s DGX Spark playbook budgets memory for the model and the KV cache together, asking for about 30 GB free for its example model, so treat the file size as the floor of your budget and check resident memory on your own machine.
| Model and quantization | File size | Where the figure comes from |
|---|---|---|
| Qwen2.5-0.5B-Instruct Q4_K_M | 491.4 MB | Our run; 587 MB resident in llama-server at 2048 context |
| Llama 3.1 8B, original size | 32.1 GB | llama-quantize README |
| Llama 3.1 8B, Q4_K_M | 4.9 GB | llama-quantize README |
Q4_K_M is a 4-bit quantization that Liquid AI’s llama.cpp guide recommends as a “good balance of quality and size”. The 8B example shows what it buys: the README lists an original size of 32.1 GB against 4.9 GB at Q4_K_M. The table below puts the other quantization levels beside it. The GB column is our conversion of the quantize page’s GiB figures (GiB times 1.0737), so the two size columns describe the same files in different units.
| Quantization | About size, 8B model (GB) | Bits per weight | Size (GiB) |
|---|---|---|---|
| Q8_0 | about 8.5, near-lossless | 8.5008 | 7.95 |
| Q6_K | about 6.6 | 6.5633 | 6.14 |
| Q5_K_M | about 5.7 | 5.7036 | 5.33 |
| Q5_K_S | about 5.6 | 5.5704 | 5.21 |
| Q4_K_M | about 4.9, the recommended default | 4.8944 | 4.58 |
| Q4_K_S | about 4.7 | 4.6672 | 4.36 |
| Q3_K_M | about 4.0 | 3.9960 | 3.74 |
| Q2_K | about 3.2, quality degraded | 3.1593 | 2.95 |
To fetch a model without a browser, -hf downloads from Hugging Face and caches it. The Hugging Face guide says the cache location is set by the LLAMA_CACHE environment variable. The README’s own example uses a repository from the project’s ggml-org organisation:
cd llama-lab/llama-b12110
./llama-cli -hf ggml-org/Qwen3.5-0.8B-GGUF
Besides the ggml-org repositories, Unsloth publishes GGUF files too. Its dynamic GGUF page reports, in an update dated 27 February 2026, that it fixed tool-calling chat template issues for Qwen3.5 and benchmarked every GGUF on perplexity and KL divergence.
For gated or private models, export a Hugging Face token before using -hf. The server README lists -hft, --hf-token with its default taken from the HF_TOKEN environment variable, so llama.cpp reads the variable and authenticates the download. Public models need no token.
export HF_TOKEN=hf_your_token_here
./llama-cli -hf ggml-org/Qwen3.5-0.8B-GGUF
Our lab loaded a local GGUF file instead, so the -hf download itself was not part of our run. By default llama.cpp, per the CLI docs, “adjusts unset options to fit your available device memory”, so out-of-memory errors at startup are rare. If a model still fails to load, try a smaller quantization or a smaller -c.
Steps 5 and 6: –mmap is rejected on b12110, -lm sets the load mode, and llama-completion runs plain prompts
Older commands break here first. On build b12110, our search of llama-cli --help for --mmap, --no-mmap, --mlock, --direct-io and --load-mode returned a single line, -lm, --load-mode MODE (model loading mode, default auto). Passing --mmap stops the program with an invalid-argument error. The project’s CLI README, checked on 12 November 2026, lists the modes -lm accepts as auto, none, mmap, mlock, mmap+mlock and dio (use DirectIO if available), with the environment variable LLAMA_ARG_LOAD_MODE. A saved command that passes --mmap should use -lm with one of those modes instead.
$ llama-cli --help | grep -E -- '--(mmap|no-mmap|mlock|direct-io|load-mode)'
-lm, --load-mode MODE model loading mode (default: auto)
$ llama-cli -m qwen.gguf --mmap -p hi -n 1
error: invalid argument: --mmap
For a first prompt, the lab used llama-completion with -no-cnv, which gives a plain completion instead of a chat. One captured run, output cut to its first two lines:
$ llama-completion -m qwen.gguf -t 4 -p 'The capital of France is' -n 16 -no-cnv
The capital of France is ____.
A. Paris
The 0.5B model continued the sentence as a multiple-choice quiz item instead of answering it. For questions, use chat: ./llama-cli -m model.gguf starts the terminal chat the CLI docs describe, and step 9 uses the chat endpoint. We did not run an interactive chat session in the lab.
Step 6 is a tuned run. On a GPU build, -ngl sets how many layers are offloaded: a high value such as 99 pushes as many as fit onto the GPU, a lower value leaves the rest on CPU, and 0 forces CPU. The server README lists --cache-type-k and --cache-type-v with f16 as the default and q8_0 among the allowed types; setting both to q8_0 shrinks the KV cache so a longer context fits. We ran no GPU, so none of the offload flags were exercised.
./llama-cli -m model.gguf -ngl 99 -c 8192 -t 8 -lm auto
| Flag | Purpose |
|---|---|
-m | Path to the GGUF file |
-hf | Download a model from Hugging Face and cache it |
-p | Prompt text (used with llama-completion in our run) |
-n | Maximum tokens to generate |
-t | CPU threads (4 in our run) |
-c | Context window in tokens (2048 in our server run) |
-no-cnv | llama-completion: plain completion, no chat |
-ngl | Layers offloaded to the GPU, on GPU builds |
--cache-type-k, --cache-type-v | KV cache data type; f16 is the default, q8_0 is allowed |
-lm, --load-mode | Model loading mode, default auto; the CLI README (checked 12 November 2026) lists auto, none, mmap, mlock, mmap+mlock and dio |
--fit | On by default; adjusts unset options to fit device memory |
Two more features are in the CLI docs. Speculative decoding needs both a main model and a drafter model, and in a chat you can attach an image with the /image command.
Step 7: 50.28 tokens/s generating and a wrong 17 times 23, from a 0.5B model on 4 CPU threads
llama-bench reports two speeds in tokens per second. Its README defines pp as prompt processing in batches (set with -p) and tg as text generation of a sequence of tokens (set with -n). In our runs, pp128 is the speed of processing a 128-token prompt and tg64 the speed of generating 64 tokens. Prompt speed matters most for long documents and retrieval workloads; generation speed is what you feel in a chat. Run it before and after you change -t, the KV cache type or -ngl to see what each change did on your hardware.
llama-bench -m qwen.gguf -t 4 -p 128 -n 64 -r 1
size | test | t/s
462.96 MiB | pp128 | 150.28 ± 0.00
462.96 MiB | tg64 | 50.28 ± 0.00
The size column reads 462.96 MiB for the model, while the file on disk is 491,400,032 bytes (about 468.6 MiB); the 491.4 MB figure used elsewhere on this page is the file size. That capture is a single run, the third of 3 separate invocations, each with -r 1, trimmed to the size, test and speed columns. The table reports all 3 invocations and their median. In this case the third run happens to equal the median for both tests.
| Measurement (Qwen2.5-0.5B Q4_K_M, 4 threads) | Unit | Run 1 | Run 2 | Run 3 | Median |
|---|---|---|---|---|---|
| Prompt processing, pp128 | tokens/s | 118.42 | 187.33 | 150.28 | 150.28 |
| Text generation, tg64 | tokens/s | 46.08 | 53.07 | 50.28 | 50.28 |
| llama-server start until /health returns ok | seconds | 0.832 | 0.737 | 0.972 | 0.832 |
| llama-server resident memory after load, 2048 context | MB | 587 | 587 | 587 | 587 |
Individual runs varied widely, so each speed figure here is the median of 3 runs. For a rough idea of what a bigger model would do, take generation at 50.28 tokens/s over a 0.4914 GB file: that is about 24.7 GB/s of weight reads (50.28 times 0.4914). If generation is limited by memory reads, an 8B Q4_K_M file of 4.9 GB would run near 5 tokens/s on this machine (24.7 divided by 4.9). That is an estimate from our numbers and the quantize README’s file size; we did not run an 8B model.
Speed is not quality. Through llama-server at temperature 0, the model was asked “What is 17 times 23? Answer with just the number.” and answered 421; the correct answer is 391. Together with the quiz fragment in step 5, that is a limit of a 0.5B model, not of llama.cpp, and it is the reason to move up in model size once the toolchain works.
Steps 8 and 9: llama-server was ready in 0.832 s, then a streaming Python client
We started llama-server -m qwen.gguf -t 4 -c 2048 --port 8089 three times. It answered /health with ok after a median 0.832 s (runs of 0.832, 0.737 and 0.972 s) and held 587 MB resident, then answered an OpenAI-style request at /v1/chat/completions with a normal response body that included token usage. The llama.app introduction describes llama serve as an OpenAI-compatible server with a built-in web interface; we ran the llama-server binary. The examples below use port 8080 instead of the 8089 from our run.
You can check each of those start times against the timings of three llama.cpp runs from our lab test.
Bind to loopback. --host 0.0.0.0 listens on every network interface and puts the model in front of anyone who can reach the machine, so the examples use 127.0.0.1. The script below starts the server, polls /health until it returns ok, sends the question from step 7, and stops the server on exit. It gives up after 30 polls, so raise that number for a model that loads slowly.
#!/bin/sh
set -e
./llama-server -m qwen.gguf -t 4 -c 2048 --host 127.0.0.1 --port 8080 &
SERVER_PID=$!
trap 'kill $SERVER_PID' EXIT
ready=0
for i in $(seq 1 30); do
if curl -fs http://127.0.0.1:8080/health | grep -q ok; then
ready=1
break
fi
sleep 1
done
[ "$ready" = 1 ] || { echo "server did not become ready" >&2; exit 1; }
curl -s http://127.0.0.1:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":"What is 17 times 23? Answer with just the number."}],"max_tokens":32,"temperature":0}'
With a server already running, the same endpoint answers a plain curl from a second terminal:
curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":"Hello"}],"max_tokens":32}'
For a multi-turn terminal chat that prints tokens as they arrive, this client uses the openai Python package (pip install openai) pointed at the local server, sets a timeout, and exits cleanly on Ctrl-C. The client library requires a model name, so the script passes the string local. It was written from the OpenAI streaming format the server speaks and not run in our lab.
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:8080/v1", api_key="not-needed", timeout=120)
history = [{"role": "system", "content": "You are a concise assistant."}]
try:
while True:
user = input("You: ")
if user.strip().lower() in {"exit", "quit"}:
break
history.append({"role": "user", "content": user})
response = client.chat.completions.create(
model="local", messages=history, stream=True
)
reply = ""
print("Bot: ", end="", flush=True)
for chunk in response:
delta = chunk.choices[0].delta.content or ""
print(delta, end="", flush=True)
reply += delta
print()
history.append({"role": "assistant", "content": reply})
except (KeyboardInterrupt, EOFError):
print()
Any client that speaks the OpenAI chat format can use the same /v1/chat/completions endpoint, as the curl and Python examples above do. The server README also lists OpenAI API compatible responses and embeddings routes next to chat completions; our lab exercised only the chat completions route.
NVIDIA’s NemoClaw documentation covers llama-server as an experimental local-inference option, on DGX Spark, Linux x86_64 with an NVIDIA GPU, or Windows WSL. NemoClaw can attach a llama-server that you operate and authenticate yourself, or select a compatible profile itself; the page calls both paths experimental and says they use OpenAI Chat Completions.
Steps 10 and 11: convert to F16, quantize to Q4_K_M, never requantize
Make your own GGUF only when none exists for the model you want, for example a model you fine-tuned. The Transformers documentation names convert_hf_to_gguf.py as the script that converts a Transformers model to GGUF. It lives in the llama.cpp source repository, so clone it as in step 3 and install its Python requirements first. Quantizing needs llama-quantize, which the source build puts in build/bin. Convert to F16 first and quantize from that file: the quantize README warns that --allow-requantize, which accepts already-quantized tensors, can severely reduce quality. Its 8B example goes from an original size of 32.1 GB to 4.9 GB at Q4_K_M, so check free disk space before you start.
pip install -r requirements.txt
df -h .
python convert_hf_to_gguf.py ./models/my-model --outfile ./models/my-model-f16.gguf --outtype f16
./build/bin/llama-quantize ./models/my-model-f16.gguf ./models/my-model-Q4_K_M.gguf Q4_K_M
These two steps were not run in our lab; they follow the project’s own READMEs. The output of step 11 loads with -m like any downloaded GGUF.
Step 12 and the command card: the service unit, the 12 commands and the errors they throw
To keep an endpoint up across reboots, run llama-server under systemd. This unit was written from standard systemd practice and not run in our lab. It copies the unpacked archive to /opt/llama, runs as a non-root user and binds to loopback.
sudo useradd --system --no-create-home llama
sudo cp -r llama-lab/llama-b12110 /opt/llama
sudo cp qwen.gguf /opt/llama/model.gguf
# /etc/systemd/system/llama.service
[Unit]
Description=llama.cpp server
After=network.target
[Service]
User=llama
ExecStart=/opt/llama/llama-server -m /opt/llama/model.gguf -t 4 -c 2048 --host 127.0.0.1 --port 8080
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now llama.service
journalctl -u llama.service -n 50
| Step | Goal | Command |
|---|---|---|
| 1 | Download build b12110 | sh get-llama.sh |
| 2 | Check the version | ./llama-cli --version |
| 3 | Build with a GPU backend | cmake -S . -B build -DGGML_CUDA=ON && cmake --build build --config Release -j |
| 4 | Pull a model | ./llama-cli -hf ggml-org/Qwen3.5-0.8B-GGUF |
| 5 | First run | ./llama-cli -m model.gguf for chat, or ./llama-completion -m model.gguf -t 4 -p "..." -n 16 -no-cnv |
| 6 | Tuned run | ./llama-cli -m model.gguf -ngl 99 -c 8192 -t 8 -lm auto |
| 7 | Benchmark | ./llama-bench -m model.gguf -t 4 -p 128 -n 64 |
| 8 | Serve | ./llama-server -m model.gguf -t 4 -c 2048 --host 127.0.0.1 --port 8080 |
| 9 | Query | curl http://localhost:8080/v1/chat/completions -H "Content-Type: application/json" -d '{"messages":[...]}' |
| 10 | Convert to F16 | python convert_hf_to_gguf.py ./models/my-model --outfile ./models/my-model-f16.gguf --outtype f16 |
| 11 | Quantize | ./build/bin/llama-quantize ./models/my-model-f16.gguf ./models/my-model-Q4_K_M.gguf Q4_K_M |
| 12 | Run as a service | sudo systemctl enable --now llama.service |
| Symptom | Cause | Fix |
|---|---|---|
error: invalid argument: --mmap | b12110 rejects the flag; its help lists -lm / --load-mode for the loading mode | Use -lm with a mode from the CLI README: auto, none, mmap, mlock, mmap+mlock or dio |
| A question returns a quiz fragment such as “____. A. Paris” | A plain completion from a very small model, run with llama-completion -no-cnv | Use llama-cli chat or /v1/chat/completions, and a larger model for reliable answers |
| The model fails to load for lack of memory | Model plus context exceeds free memory; resident memory ran above the file size (587 MB for a 491.4 MB file at 2048 context) | Choose a smaller quantization or lower -c |




