Prerequisites
- CMake 3.14 or later
- A C11 / C++17 compiler: GCC, Clang, or MSVC
- Git
Basic build
ggml library and all examples in build/bin/. The
default build targets the CPU backend with native ISA optimizations enabled.
Backend builds
- CUDA
- Metal
- Vulkan
- HIP (AMD)
Requires the NVIDIA CUDA Toolkit (tested with CUDA 11.x and 12.x) and a
compatible NVIDIA GPU. Ensure
nvcc is on your PATH.General CMake options
These options apply to all build configurations.CPU instruction set options
When
GGML_NATIVE=ON (the default), the compiler detects and enables all
supported ISA extensions automatically. Set individual flags only when
cross-compiling or targeting a specific baseline.
Example — build for a fixed AVX2 baseline without native detection:
