Skip to main content
llama.cpp can be installed via package managers for quick setup, or built from source for GPU acceleration and custom configurations. The easiest way to install llama.cpp is through your system’s package manager. These pre-built binaries work out-of-the-box but typically only include CPU support.

Homebrew

macOS and Linux
Automatically updated with new releases.

Winget

Windows
Automatically updated with new releases.

MacPorts

macOS
More info →

Nix

macOS and Linux
Package manager installations are ideal for getting started quickly. For GPU acceleration, you’ll need to build from source.

Docker Images

Pre-built Docker images are available with and without GPU support:
Three image variants are available:
Example usage:

Pre-Built Binaries

Download pre-compiled binaries directly from GitHub:
  1. Visit the releases page
  2. Download the appropriate binary for your platform
  3. Extract and add to your PATH
Pre-built binaries may not include all GPU backends. For full GPU support, build from source.

Building from Source

Building from source enables GPU acceleration and custom configurations.
1

Get the source code

Clone the repository:
2

Choose your build configuration

Select the appropriate build for your hardware:
Basic CPU build with no dependencies:
For faster compilation:
Enable BLAS acceleration for faster prompt processing:
3

Install (optional)

Install the binaries to your system:
Or use directly from the build directory:
4

Verify GPU support

Check that GPU acceleration is working:
You should see output indicating GPU layers are loaded:

Platform-Specific Instructions

Prerequisites:
  • Visual Studio 2022 with C++ development tools
  • CMake (included with VS)
Build:
For ARM64 Windows:
Building for Android requires the NDK. See the Android build guide for complete instructions.Quick example with OpenCL:
For portable binaries without shared library dependencies:
Single-config generators (Make, Ninja):
Multi-config generators (Visual Studio, Xcode):

Advanced Build Options

ccache for faster rebuilds:
Intel oneMKL for better CPU performance:

Verifying Installation

Test your installation:
Expected output should show:
  • Version information
  • Detected backends (CUDA, Metal, etc.)
  • Model loading messages
  • Generated text

Troubleshooting

Issue: Could NOT find CUDASolutions:
Issue: cannot find ROCm device librarySolution:
Issue: CMake can’t find VulkanSolutions:
Solutions:
Issue: GPU detected but errors during inferenceSolutions:
  • Update GPU drivers to the latest version
  • Try reducing layers offloaded: -ngl 30 instead of -ngl 99
  • Check VRAM usage: ensure model fits in available memory
  • For CUDA: try setting CUDA_VISIBLE_DEVICES=0
  • For ROCm: try setting HIP_VISIBLE_DEVICES=0

Next Steps

Quick Start

Learn how to run your first inference and use common features

CLI Reference

Explore all available command-line options

Build Documentation

Detailed build instructions and advanced configurations

Docker Guide

Complete Docker setup and usage guide