Skip to main content

Prerequisites

  • CMake 3.14 or later
  • A C11 / C++17 compiler: GCC, Clang, or MSVC
  • Git
Backend-specific requirements are listed in the relevant sections below.

Basic build

This produces the core ggml library and all examples in build/bin/. The default build targets the CPU backend with native ISA optimizations enabled.

Backend builds

Requires the NVIDIA CUDA Toolkit (tested with CUDA 11.x and 12.x) and a compatible NVIDIA GPU. Ensure nvcc is on your PATH.
Additional CUDA options:

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: