Development
Install prerequisites:- Go
- C/C++ Compiler e.g. Clang on macOS, TDM-GCC (Windows amd64) or llvm-mingw (Windows arm64), GCC/Clang on Linux.
[!NOTE]
Ollama includes native code compiled with CGO. From time to time these data structures can change and CGO can get out of sync resulting in unexpected crashes. You can force a full build of the native code by running go clean -cache first.
macOS (Apple Silicon)
macOS Apple Silicon supports Metal which is built-in to the Ollama binary. No additional steps are required.macOS (Intel)
Install prerequisites:- CMake or
brew install cmake
Windows
Install prerequisites:- CMake
- Visual Studio 2022 including the Native Desktop Workload
- (Optional) AMD GPU support
- (Optional) NVIDIA GPU support
- (Optional) VULKAN GPU support
- VULKAN SDK - useful for AMD/Intel GPUs
- (Optional) MLX engine support
Building for Vulkan requires VULKAN_SDK environment variable: PowerShellCMD
[!IMPORTANT] Building for ROCm requires additional flags:Lastly, run Ollama:
Windows (ARM)
Windows ARM does not support additional acceleration libraries at this time. Do not use cmake, simplygo run or go build.
Linux
Install prerequisites:- CMake or
sudo apt install cmakeorsudo dnf install cmake - (Optional) AMD GPU support
- (Optional) NVIDIA GPU support
- (Optional) VULKAN GPU support
- VULKAN SDK - useful for AMD/Intel GPUs
- Or install via package manager:
sudo apt install vulkan-sdk(Ubuntu/Debian) orsudo dnf install vulkan-sdk(Fedora/CentOS)
- (Optional) MLX engine support
- CUDA 13+ SDK
- cuDNN 9+
- OpenBLAS/LAPACK:
sudo apt install libopenblas-dev liblapack-dev liblapacke-dev(Ubuntu/Debian)
[!IMPORTANT]
Ensure prerequisites are in PATH before running CMake.
Then, configure and build the project:
MLX Engine (Optional)
The MLX engine enables running safetensor based models. It requires building the MLX and MLX-C shared libraries separately via CMake. On MacOS, MLX leverages the Metal library to run on the GPU, and on Windows and Linux, runs on NVIDIA GPUs via CUDA v13.macOS (Apple Silicon)
Requires the Metal toolchain. Install Xcode first, then:
[!NOTE]
Without the Metal toolchain, cmake will silently complete with Metal disabled. Check the cmake output for Setting MLX_BUILD_METAL=OFF which indicates the toolchain is missing.
Windows / Linux (CUDA)
Requires CUDA 13+ and cuDNN 9+.Local MLX source overrides
To build against a local checkout of MLX and/or MLX-C (useful for development), set environment variables before running CMake:Docker
ROCm
Running tests
To run tests, usego test:
NOTE: In rare circumstances, you may need to change a package using the new “synctest” package in go1.24. If you do not have the “synctest” package enabled, you will not see build or test failures resulting from your change(s), if any, locally, but CI will break. If you see failures in CI, you can either keep pushing changes to see if the CI build passes, or you can enable the “synctest” package locally to see the failures before pushing. To enable the “synctest” package for testing, run the following command:If you wish to enable synctest for all go commands, you can set theGOEXPERIMENTenvironment variable in your shell profile or by using:Which will enable the “synctest” package for all go commands without needing to set it for all shell sessions. The synctest package is not required for production builds.
Library detection
Ollama looks for acceleration libraries in the following paths relative to theollama executable:
./lib/ollama(Windows)../lib/ollama(Linux).(macOS)build/lib/ollama(for development)

