Package Managers (Recommended for CPU)
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 LinuxAutomatically updated with new releases.
Winget
WindowsAutomatically updated with new releases.
MacPorts
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:- CPU
- CUDA
- ROCm
- Other GPUs
Three image variants are available:Example usage:
Pre-Built Binaries
Download pre-compiled binaries directly from GitHub:- Visit the releases page
- Download the appropriate binary for your platform
- Extract and add to your PATH
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:
- CPU Only
- NVIDIA GPU (CUDA)
- AMD GPU (ROCm)
- Apple Silicon (Metal)
- Intel GPU (SYCL)
- Vulkan
Basic CPU build with no dependencies:For faster compilation:
Optional: OpenBLAS for better CPU performance
Optional: OpenBLAS for better CPU performance
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
Windows with Visual Studio
Windows with Visual Studio
Prerequisites:For ARM64 Windows:
- Visual Studio 2022 with C++ development tools
- CMake (included with VS)
Android
Android
Building for Android requires the NDK. See the Android build guide for complete instructions.Quick example with OpenCL:
Static builds
Static builds
For portable binaries without shared library dependencies:
Debug builds
Debug builds
Single-config generators (Make, Ninja):Multi-config generators (Visual Studio, Xcode):
Advanced Build Options
- Performance
- Multiple Backends
- Special Hardware
- SSL/TLS Support
ccache for faster rebuilds:Intel oneMKL for better CPU performance:
Verifying Installation
Test your installation:- Version information
- Detected backends (CUDA, Metal, etc.)
- Model loading messages
- Generated text
Troubleshooting
CMake can't find CUDA
CMake can't find CUDA
Issue:
Could NOT find CUDASolutions:ROCm build errors
ROCm build errors
Issue:
cannot find ROCm device librarySolution:Vulkan SDK not found
Vulkan SDK not found
Issue: CMake can’t find VulkanSolutions:
Compilation is very slow
Compilation is very slow
Solutions:
Runtime GPU errors
Runtime GPU errors
Issue: GPU detected but errors during inferenceSolutions:
- Update GPU drivers to the latest version
- Try reducing layers offloaded:
-ngl 30instead 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

