Skip to main content
Local AI

llama.cpp Guide: Install, Run, Server and Fixes (2026)

How to install llama.cpp on Windows, Mac or Linux, download GGUF models, run llama serve, set the context size and fix Smart App Control blocks.

Advertisement
Updated 1 Dec 2026
Advertisement
Quick answer: llama.cpp is the free, open-source engine that runs GGUF language models on your own CPU or GPU. Since version 1.0 (November 2026) it ships as one program called llama: install it with irm https://llama.app/install.ps1 | iex on Windows (or curl -LsSf https://llama.app/install.sh | sh on Mac and Linux), then run llama cli -hf ggml-org/Qwen3.5-0.8B-GGUF to chat or llama serve -hf ggml-org/Qwen3.5-0.8B-GGUF for an OpenAI-compatible server and chat page at http://127.0.0.1:9931. Use -c to set the context size.
CheckedThe install steps, command list, server test and error messages on this page were run on 1 December 2026 on a Windows 11 Pro test PC (Intel Xeon E5-2665, 32 GB RAM, AMD Radeon RX 580 8 GB) with Smart App Control switched on. Versions tested: llama.cpp build 12826 (1.1.0-dev) from llama.app and build 12855 from winget. Flags, paths and the API come from the official llama.cpp documentation and source code, linked at the end.

What is llama.cpp?

llama.cpp is an LLM inference engine written in C and C++, built on the ggml tensor library and maintained by the ggml-org team at Hugging Face. It loads models in the GGUF file format, usually quantised to 4 to 8 bits so they fit in ordinary RAM or VRAM, and runs them on CPUs and on NVIDIA (CUDA), AMD (ROCm or Vulkan), Intel and Apple Silicon (Metal) hardware. The project says it supports more than 150 model architecture variants.

Two things changed recently, and many older guides have not caught up:

Advertisement

How to install llama.cpp

The README lists four ways. In order of how easy they are:

MethodCommandGood for
Official installer (Windows)irm https://llama.app/install.ps1 | iexMost Windows users. Picks the right GPU build for you.
Official installer (Mac, Linux)curl -LsSf https://llama.app/install.sh | shMost Mac and Linux users.
Package managerwinget install llama.cpp, brew install llama.cpp, conda install -c conda-forge llama.cppPeople who update everything through one tool.
Dockerghcr.io/ggml-org/llama.cpp:server (plus -cuda, -rocm, -vulkan variants)Servers and homelabs.
Build from sourcecmake -B build then cmake --build build --config ReleaseCustom GPU flags or the very latest code.

Install llama.cpp on Windows

Open PowerShell (no admin needed) and run:

irm https://llama.app/install.ps1 | iex

The script checks for a CUDA GPU first, then ROCm, then Vulkan, then falls back to a CPU build, and downloads the matching single llama.exe. It installs it to %LOCALAPPDATA%\Microsoft\WindowsApps\llama.exe, which is already on the PATH, so llama works in any new terminal. On the test PC it found no CUDA or ROCm, picked the Vulkan build, and finished with Installation completed successfully. The file was 53 MB and signed by Hugging Face.

Check it worked:

PS> llama version
version: 1.1.0-dev (build 12826, commit 8e23278c7)
built with Clang 22.1.8 for Windows x86_64

PS> llama serve --list-devices
Available devices:
  Vulkan0: Radeon RX 580 Series (8192 MiB, 7402 MiB free)

If you have an NVIDIA card but the script says NVIDIA GPU detected, but the CUDA Toolkit is not installed, install the CUDA Toolkit (the script suggests winget install Nvidia.CUDA) and run the installer again. Otherwise you get the Vulkan or CPU build.

winget instead? winget install llama.cpp works and installs llama.exe, llama-server.exe, llama-cli.exe, llama-bench.exe, llama-quantize.exe and the other tools, with CPU and Vulkan back ends (the package tested had no CUDA DLLs). But read the Smart App Control section below first: on the test PC every winget program was blocked.

Install llama.cpp on Mac or Linux

# official installer
curl -LsSf https://llama.app/install.sh | sh

# or Homebrew (Mac and Linux)
brew install llama.cpp

Apple Silicon Macs use the Metal GPU back end. Linux users with NVIDIA cards who want to build it themselves add -DGGML_CUDA=ON to the cmake step.

Run llama.cpp in Docker

The official images are full, light and server, each with -cuda, -cuda13, -rocm, -vulkan, -intel, -musa and -openvino variants. This is the example from the server README:

docker run -p 8080:8080 -v /path/to/models:/models --gpus all \
  ghcr.io/ggml-org/llama.cpp:server-cuda \
  -m /models/your-model.gguf -c 4096 --host 0.0.0.0 --port 8080 --n-gpu-layers 99

Build llama.cpp from source

git clone https://github.com/ggml-org/llama.cpp
cd llama.cpp
cmake -B build                      # add -DGGML_CUDA=ON for NVIDIA, -DGGML_VULKAN=ON for Vulkan
cmake --build build --config Release -j 8

On Windows the build guide uses Visual Studio 2022 with the C++ CMake tools and the Clang components. Most people do not need to build it: the installers above already include GPU support.

llama.cpp commands

This is what llama help all printed on the test PC (build 12826):

CommandWhat it doesOld separate program
llama serveHTTP API server plus the Llama Chat web pagellama-server
llama cliInteractive chat in the terminalllama-cli
llama downloadDownloads a model without running itnone
llama updateUpdates to the latest release (installer builds only)none
llama completionPlain text completion, no chat templatellama-completion
llama benchMeasures prompt and generation speedllama-bench
llama fit-paramsWorks out settings that fit a model in your memoryllama-fit-params
llama quantizeMakes a smaller quantised GGUF from a bigger onellama-quantize
llama perplexityMeasures model quality (perplexity, KL divergence)llama-perplexity
llama versionShows the version and build--version

Every command takes --help. llama server and llama client also work as aliases for serve and cli.

How to download models for llama.cpp

llama.cpp runs GGUF files. You can point it at a file you already have with -m, or let it fetch one from Hugging Face with -hf:

# download only
llama download -hf ggml-org/Qwen3.5-0.8B-GGUF

# pick a quantisation with :TAG
llama serve -hf ggml-org/Qwen3.5-0.8B-GGUF:Q8_0

# a file on disk
llama serve -m C:\models\my-model-Q4_K_M.gguf

# list what is already downloaded
llama cli -cl

Without a tag, llama.cpp looks for Q4_K_M and falls back to another file in the repository if there is none. The test repository had no Q4_K_M, and llama.cpp chose the Q8_0 file (795 MB). It also downloaded the 111 MB vision projector (mmproj) on its own, because the model can read images; add --no-mmproj if you do not want it. The download took 22 seconds.

Where the models go. Current builds store -hf downloads in the standard Hugging Face cache, so they are shared with other Hugging Face tools:

Gated models need a Hugging Face token: set the HF_TOKEN environment variable or pass --hf-token. Not sure which size fits your card? Check the LLM VRAM calculator and the quantisation guide (Q4_K_M, Q8_0 and the rest explained).

How to run llama.cpp as a server (llama serve)

llama serve -hf ggml-org/Qwen3.5-0.8B-GGUF:Q8_0

On the test PC the server answered /health with 503 while the model loaded and {"status":"ok"} after 10 seconds. The log ended with listening on http://127.0.0.1:9931. Open that address in a browser for Llama Chat, the built-in chat page (turn it off with --no-ui).

The server speaks the OpenAI API (/v1/chat/completions, /v1/completions, /v1/responses, /v1/embeddings, /v1/models) and the Anthropic Messages API (/v1/messages), so most apps that let you set a “base URL” can use it. A test request:

curl http://127.0.0.1:9931/v1/chat/completions -H "Content-Type: application/json" -d "{\"messages\":[{\"role\":\"user\",\"content\":\"In one sentence, what is llama.cpp?\"}],\"max_tokens\":300}"

Each reply includes a timings block. On the RX 580 test card, the 0.8B model generated about 31 to 33 tokens per second. A model that small is only good for checking that everything works: its one-sentence answer about llama.cpp was wrong. Use a bigger model for real work.

Useful server options

OptionWhat it doesDefault
--port 8080Port to listen on9931
--host 0.0.0.0Listen on your network, not only this PC127.0.0.1
--api-key KEYRequire a key on API calls (do this before opening it to the network)none
-c 8192Context size in tokens0 = the model’s own maximum
-ngl NLayers to put on the GPU: a number, auto or allauto
-np 2Parallel request slots4 slots on the test PC
--reasoning offTurn off thinking for models that support itauto
--models-dir PATHRouter mode: serve every GGUF in a folder and load them on demandoff
--no-uiTurn off the built-in chat pageon

Several models in one server. Start llama serve with no model (it then lists your downloaded models), or with --models-dir pointing at a folder of GGUF files. The server becomes a router: each request picks a model with its "model" field, and up to 4 models stay loaded by default (--models-max). Put multi-file models (vision projectors, split files) in their own sub-folder.

How to increase the context size in llama.cpp

Use -c (or --ctx-size) with a number of tokens:

llama serve -hf ggml-org/Qwen3.5-0.8B-GGUF:Q8_0 -c 8192

The default is 0, which means “use the model’s own maximum”. For the test model that was 262,144 tokens, and the /props endpoint showed n_ctx=262144. With -c 8192 it showed n_ctx=8192. A bigger context needs more memory for the KV cache, so on a small GPU a lower number can be faster. The --fit option (on by default) adjusts settings you did not set so the model fits in device memory, and it will not push the context below 4,096 tokens (--fit-ctx). To save memory on long contexts, the KV cache can be stored at lower precision with -ctk q8_0 -ctv q8_0.

Advertisement

Best llama.cpp settings

Current builds pick sensible values for most options, so start with no flags and change one thing at a time:

How to update llama.cpp

On other installs, llama update only says Updates are available only when installed from https://llama.app.

llama.cpp vs Ollama vs LM Studio

llama.cppOllamaLM Studio
What it isThe engine itself, command line plus a small chat pageA background service with its own model libraryA desktop app with a model browser
ModelsAny GGUF file, straight from Hugging Faceollama pull names from its library, or imported GGUFDownloads models from inside the app
Default API port993111434Local server started from the app
ControlEvery flag exposedFewer options, simplerSettings in menus
Best forThe newest models and full control“Just works” use and apps built for OllamaPeople who prefer a GUI

If you already use Ollama, the Ollama commands cheat sheet covers its equivalents (pull, run, ps, context length, model folder). For more local AI guides, see the local LLMs hub.

When llama.cpp breaks: common errors

“An Application Control policy has blocked this file” (Windows)

This was the first thing that went wrong on the test PC. With Smart App Control switched on, every program from the winget package (build 12855) was blocked. PowerShell showed An Application Control policy has blocked this file. llama.exe printed nothing at all and exited with code 0xC0E90002. The Code Integrity event log listed “Smart App Control” blocks (event IDs 3033, 3077 and 3118) when llama.exe tried to load its own DLLs. Get-AuthenticodeSignature showed the winget files as NotSigned.

Microsoft says Smart App Control blocks unsigned apps it cannot vouch for, and “there is currently no way to bypass” it for single apps. What worked on the test PC, without changing any Windows setting: use the llama.app installer instead. Its llama.exe carries a valid Hugging Face signature and ran normally with Smart App Control still on. The other option is to turn Smart App Control off in the Windows Security app. Microsoft’s page says recent Windows updates let you turn it back on later without reinstalling Windows.

To check whether Smart App Control is on: (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\CI\Policy').VerifiedAndReputablePolicyState returns 1 when it is on (it was on the test PC).

Empty reply: “content” is blank

With a thinking model, a request with "max_tokens":120 came back with "content": "". All 120 tokens went into reasoning_content (the model’s thinking) and it never reached the answer. Fixes, both tested:

Cloud APIs have the same trap. See why the Claude API returns an empty response when thinking uses up max_tokens.

App cannot connect, or “Loading model”

Slow, or running on the CPU instead of the GPU

“unknown model architecture” or a new model will not load

New model families need a newer llama.cpp. Update first (see above): release notes list newly supported models, for example v1.1.0 added the Inkling 2 family and several speech models.

FAQ

Is llama.cpp free?

Yes. It is open source under the MIT licence, on GitHub at ggml-org/llama.cpp.

Does llama.cpp need a GPU?

No. It runs on the CPU alone, with builds for many CPU generations. A GPU makes it much faster: NVIDIA through CUDA, AMD through ROCm or Vulkan, Intel through SYCL, OpenVINO or Vulkan, and Apple Silicon through Metal. The test PC used an AMD Radeon RX 580 through Vulkan.

How do I use llama.cpp, step by step?

Install it (one command), run llama serve -hf USER/MODEL-GGUF, open http://127.0.0.1:9931 in your browser and chat. Or run llama cli -hf USER/MODEL-GGUF to chat in the terminal.

What happened to llama-server and llama-cli?

They still exist in the winget, Homebrew and release packages. The llama.app installer gives you only the single llama program, where llama serve and llama cli do the same jobs with the same options.

Can llama.cpp run models from Ollama or LM Studio?

It runs any GGUF file with -m path\to\file.gguf, so a GGUF you downloaded for LM Studio works directly. Hugging Face repositories are the simplest source with -hf.

Sources

Updated 1 December 2026 (llama.cpp v1.1.0, nightly build 12887). Written with AI help from the sources listed; the Windows tests were run on the test PC described at the top.

Advertisement