← Back to articles Blog

llama.cpp: The Fastest Way to Run LLMs on CPU

Emmanuel Ekunsumi · 5 min read · 2026-07-19

llama.cpp is an open-source C++ library for running large language models on consumer hardware — including CPU-only machines. Created by Georgi Gerganov in 2023, it enabled the first practical local LLM inference without a GPU and remains the most hardware-flexible inference engine available.

What makes llama.cpp different

Most LLM inference tools require NVIDIA GPUs and CUDA. llama.cpp uses highly optimized CPU inference with optional GPU acceleration — making it the only option for:

GGUF: the format that made it possible

llama.cpp introduced GGUF (GPT-Generated Unified Format) — a quantization format that dramatically reduces model size without proportional quality loss. A 70B model that normally requires 140GB at FP16 can run in 40GB at Q4 quantization, or 24GB at Q3.

QuantizationSize (70B model)Quality vs FP16Speed
FP16 (full)~140GB100%Slowest
Q8_0~70GB~99%Fast
Q5_K_M~50GB~97%Faster
Q4_K_M~40GB~95%Faster
Q3_K_M~30GB~90%Fastest

Getting started with llama.cpp

git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
make -j4

# Download a GGUF model from Hugging Face
# Then run inference
./llama-cli -m models/llama-3.2-8b-q4_k_m.gguf -p "Hello, world" -n 128

# Run as an OpenAI-compatible server
./llama-server -m models/llama-3.2-8b-q4_k_m.gguf --port 8080

The server mode exposes an OpenAI-compatible API, so you can point Tokoscope or any other tool at it directly.

llama.cpp vs Ollama vs vLLM

llama.cppOllamavLLM
Setup difficultyHard (compile from source)Easy (one command)Medium
GPU requiredNo (CPU works)No (CPU works)Yes (NVIDIA)
ThroughputLow-mediumMediumHighest
Hardware supportWidest (CPU, CUDA, Metal, Vulkan)GoodNVIDIA only
Best forCPU inference, maximum compatibilityLocal dev, ease of useProduction serving

When to use llama.cpp

For most local development use cases, Ollama (which uses llama.cpp under the hood) is easier. For production serving on NVIDIA hardware, vLLM is faster. llama.cpp shines when neither of those apply.

Tip: llama.cpp's server mode is OpenAI-compatible, so you can wrap it with Tokoscope to track CPU inference costs alongside your cloud API calls.

Track llama.cpp inference costs alongside cloud APIs

Tokoscope works with any OpenAI-compatible endpoint including llama.cpp server mode. Free to start.

Get started free →