llama.cpp
llama.cpp is an open-source C/C++ implementation of LLM inference optimized for CPU and GPU, known for running large models locally on modest hardware with quantized formats.
llama.cpp is a high-performance, open-source implementation of LLaMA-based large language models written in C/C++. It was created by Georgi Gerganov and has become one of the most popular tools for running LLMs locally on consumer hardware, including laptops, desktops, and even Raspberry Pis. Its key innovation is the GGUF format (replacing the older GGML format), which packages model weights, tokenizer, and metadata into a single file with support for multiple quantization levels. llama.cpp supports a wide range of quantization types, including Q2_K, Q3_K, Q4_K_M, Q5_K_M, Q6_K, Q8_0, and FP16. These allow models to be compressed from their original FP16 size (e.g., 7B model ~13GB) down to as little as 3-4GB while retaining reasonable quality. The engine supports CPU inference using SIMD optimizations (AVX2, AVX512, NEON) and GPU acceleration via backends for CUDA, Metal, Vulkan, ROCm, and SYCL. It also supports multi-GPU setups, speculative decoding, and batching for batched inference. For AI builders, llama.cpp is often used for prototyping, local development, and embedded applications where cloud GPUs are unavailable. It provides a simple command-line interface and an HTTP server with an OpenAI-compatible API. llama.cpp can also be compiled as a library and linked into other applications, making it a versatile building block. It supports various model architectures, including Llama 2/3, Mistral, Gemma, Phi, and many more. Performance is competitive with vLLM for single-user scenarios, though vLLM typically excels in high-throughput server settings.
llama.cpp is not limited to LLaMA models; it supports a wide range of architectures including Mistral, Falcon, Gemma, and GPT-NeoX.
Related terms
Concepts you'll usually encounter alongside this one.
GGUF is a binary format for storing quantized LLM models, designed for efficient CPU and GPU inference, superseding GGML.
Ollama is a user-friendly tool for running and managing local LLMs, wrapping llama.cpp and providing simple CLI to pull, run, and customize models.
Q4_K_M is a 4-bit quantization method in llama.cpp that combines 4-bit quantization for most weights with higher precision for important weights using a block size of 32.
Mentioned in tutorials
Hands-on guides that put this concept to work.
Stand up a fully functional local LLM stack on Ubuntu 22.04, NVIDIA drivers, CUDA, Ollama, and your first model, in under 30 minutes.
Run local LLMs on Windows 11 the right way, WSL2, the WSL CUDA toolkit, and Ollama with full GPU acceleration. Native installer covered too.
Apple Silicon is shockingly good at LLM inference. Get Ollama running with unified memory acceleration on any M-series Mac in 15 minutes.
DeepSeek's reasoning model rivals GPT-4 on math and code. Run the distilled 7B/14B/32B variants on consumer hardware in 30 minutes.
See how this term affects your memory budget.
Real numbers, real chips, every workload.
Picks for builders, by use case.
Stay Ahead of the AI Curve
Get weekly AI hardware news, benchmark updates, and deals in your inbox. Founding-subscriber list, be one of the first.