Ollama vs llama.cpp: which one to run local models with

Ollama started as a friendly wrapper around llama.cpp and now runs engines of its own. Here is what each one does for you, what it hides, and how to choose.

Type
Comparison
Last reviewed
November 22, 2026
Sources cited
11 sources ↓

The short answer

Ollama and llama.cpp both run open-weight models on your own hardware, both read GGUF files, and both serve an OpenAI-compatible API. The difference is how much they decide for you. Ollama is a model manager: it downloads models by name, picks settings, loads and unloads them as requests arrive, and runs as a background service. llama.cpp is the engine and its tools: you choose the file, the quantization, the context size and every flag.

  • Choose Ollama when you want a model running in a few minutes, switch between several models, or point an app or coding agent at a local endpoint that is always on.
  • Choose llama.cpp when you want control over each setting, the option to build from the latest commit for new models and backends, your own quantized files, or a single binary to embed or ship.
  • Choose neither when you are serving many users at once from datacenter GPUs. That is a job for a throughput-oriented server; our vLLM vs llama.cpp comparison covers where that line falls.

Also weighing a desktop app that runs llama.cpp for you? See LM Studio vs Ollama.

llama.cpp is a C/C++ project from ggml-org, built on its own tensor library, ggml. It defined the GGUF file format and ships command-line tools such as llama-cli, llama-server, llama-bench and llama-quantize.

Ollama is a separate project, written in Go, that began by running models through llama.cpp. In May 2025 it introduced its own engine, first for multimodal models; its maintainers have said it has since moved off llama.cpp as a wrapper while still using the ggml library. In 2026 Ollama added an MLX-based engine on Apple Silicon, first released as a preview. Which engine runs a given model depends on the model and your Ollama version.

So the two share a lineage and a file format, but they are no longer the same code underneath. A model that works in one is not guaranteed to work, or behave identically, in the other, and new model architectures can arrive in one before the other. Check each project's release notes for the model you want.

Ollama and llama.cpp at a glance

Ollamallama.cpp
Written inGo, with ggml-based and MLX enginesC/C++ on ggml
What you installDesktop app (macOS, Windows) or a Linux install script; Docker imagePrebuilt binaries, package managers, Docker images, or a CMake build
Getting a modelollama pull or ollama run by name from the ollama.com library, or hf.co/<user>/<repo> from Hugging Face-hf <user>/<repo> downloads a GGUF from Hugging Face, or -m points at a local file
Model formatsIts library, plus GGUF files and Safetensors directories imported with a ModelfileGGUF; convert Hugging Face checkpoints with convert_hf_to_gguf.py and quantize with llama-quantize
SettingsChosen for you; override in a Modelfile, per request, or with environment variablesEvery option is a command-line flag (-c, -ngl, -np, sampling, cache types and more)
ServerBackground service on port 11434, with its own API and OpenAI-compatible /v1 endpointsllama-server on port 8080 by default, OpenAI-compatible, with a built-in web UI
Several modelsLoads models on request and unloads idle onesOne model per server, or router mode in recent builds to load and switch between several
CloudOptional cloud-hosted models; can be turned off for local-only useNone; everything runs where you run it
LicenseMITMIT

Both projects release often and their defaults change. Check the Ollama docs and the llama.cpp README for the version you have installed.

Getting and building models

With Ollama, a model is a name and a tag. ollama run llama3.2 downloads it from the Ollama library if needed and opens a chat. The library chooses the quantization for each tag, so read the tag list on ollama.com if you care which one you get. Any GGUF repository on Hugging Face can also be run by its path:

ollama run hf.co/<user>/<repo>
ollama run hf.co/<user>/<repo>:Q4_K_M

To use your own file, or to bake in a system prompt and parameters, write a Modelfile and build a named model from it:

# Modelfile
FROM ./my-model.gguf
PARAMETER num_ctx 16384
SYSTEM "You are a concise assistant."

ollama create my-model -f Modelfile
ollama run my-model

llama.cpp takes a file or a Hugging Face repository directly, and gives you the whole pipeline from checkpoint to quantized GGUF. That is the route to take when you want a quantization nobody has published, an importance matrix of your own, or a fine-tune you just trained:

llama-server -hf <user>/<repo>:Q4_K_M

python convert_hf_to_gguf.py ./my-checkpoint --outfile model-f16.gguf
llama-quantize model-f16.gguf model-Q4_K_M.gguf Q4_K_M

Lower-bit files fit in less memory but lose some accuracy, and how much depends on the model and the method. Our GPTQ vs AWQ comparison explains the trade-offs behind weight quantization in general.

Context, memory and the defaults that bite

Most "Ollama is worse than llama.cpp" (or the reverse) reports come down to different settings, not different engines. Three defaults matter most.

  • Context length. Ollama sets a default context for you. Its current docs tie it to GPU memory: 4K tokens under 24 GiB of VRAM, 32K from 24 to 48 GiB, and 256K at 48 GiB or more, though older releases used smaller fixed defaults. Raise it with OLLAMA_CONTEXT_LENGTH, num_ctx in a Modelfile or request, or /set parameter num_ctx in a chat. If long prompts seem to be forgotten, check this first. In llama.cpp you set it with -c; see llama-server --help for your build's default.
  • GPU offload. Ollama decides how many layers fit on the GPU and puts the rest in system memory; ollama ps shows the split (for example 100% GPU or 48%/52% CPU/GPU). llama.cpp lets you choose with -ngl, and the split can be tuned layer by layer.
  • KV-cache precision. Both can store the attention cache in 8-bit or 4-bit to save memory on long contexts: OLLAMA_KV_CACHE_TYPE for all models in Ollama, --cache-type-k and --cache-type-v per server in llama.cpp. A quantized cache generally needs flash attention enabled (in llama.cpp, for the V cache).

Ollama also keeps a model in memory for five minutes after its last request, then unloads it, so the next request pays the load time again. Change that with keep_alive per request or OLLAMA_KEEP_ALIVE for the server; -1 keeps it loaded. llama.cpp keeps its model loaded for as long as the server runs, unless you use router mode.

Concurrency and running several models

Ollama handles two kinds of concurrency. OLLAMA_MAX_LOADED_MODELS caps how many different models stay loaded at once (three per GPU by default, if they fit), and OLLAMA_NUM_PARALLEL sets how many requests one model processes at the same time. That second setting defaults to 1 on most backends, so a second request waits in a queue (up to OLLAMA_MAX_QUEUE, 512 by default) until the first finishes. Each extra parallel request adds its own share of context memory.

llama-server serves one model with a number of parallel slots, set with -np, and batches across them. Its router mode, added in December 2025, starts with no model, discovers GGUF files in its cache or a --models-dir folder, loads whichever one a request names, and evicts the least recently used model past --models-max. That covers much of what people used to choose Ollama for, with llama.cpp's flags still available per model through a presets file.

Neither is built to serve dozens of simultaneous users on datacenter GPUs. If that is where you are heading, read our vLLM architecture and PagedAttention internals piece for what a throughput-first server does differently.

Which to pick for your situation

You want toStart withWhy
Try a model on a laptop in minutesOllamaOne install, models by name, sensible defaults
Back a desktop app, editor plugin or coding agent with a local endpointOllamaMany tools ship with Ollama support, and it runs as a service that loads models on demand
Run a model the day its support lands, or a less common architecturellama.cppYou can build llama.cpp from the latest commit; Ollama adds models with its own releases, so check its release notes
Run your own fine-tune or a custom quantizationllama.cppConversion and quantization tools come with it; Ollama can then import the resulting GGUF
Tune memory on a GPU that barely fits the modelllama.cppDirect control over offloaded layers, context, cache types and batch sizes
Ship inference inside your own program or devicellama.cppA C/C++ library and small binaries with no background service
Serve many concurrent users from GPUsNeitherLook at a throughput-oriented server; see vLLM vs llama.cpp

How to compare them on your machine

Published speed comparisons rarely hold the model file, context length, offload and engine version constant, so treat them as hints. To compare fairly, load the same GGUF in both, match the context length and GPU offload, and measure prompt processing and generation speed separately.

ollama run --verbose prints timing after each answer, including prompt and generation rates. In llama.cpp, llama-bench measures both for one stream, and llama-server is what you load-test:

ollama run --verbose my-model

llama-bench -m my-model.gguf -p 1024 -n 256
llama-server -m my-model.gguf -c 16384 -ngl 99

Because both serve OpenAI-compatible endpoints (http://localhost:11434/v1 for Ollama, http://localhost:8080/v1 for llama-server), you can point the same client or load generator at each and change only the base URL. Flags and defaults change between releases; check ollama serve --help, the Ollama FAQ and the llama-server README for your version.

Sources

  1. Ollama documentation
  2. Ollama FAQ: context, concurrency, keep-alive and KV cache
  3. Ollama docs: context length
  4. Ollama docs: importing a model
  5. Ollama docs: Modelfile reference
  6. Ollama blog: new engine for multimodal models (May 2025)
  7. Ollama blog: MLX on Apple Silicon in preview (March 2026)
  8. Hugging Face docs: use Ollama with any GGUF model on the Hub
  9. llama.cpp on GitHub
  10. llama.cpp HTTP server README
  11. New in llama.cpp: model management (router mode)