Build

Building from source

Edit on GitHub

You only need this if you're hacking on mlx-serve. To just use it, grab the app or brew install mlx-serve.

Prerequisites

App + server

One script builds everything:

git clone --recurse-submodules https://github.com/ddalcu/mlx-serve && cd mlx-serve
brew bundle install --file=Brewfile
./app/build.sh
open "app/MLX-Serve.app"

app/build.sh snaps the pinned submodules back to their commits, stages llama.cpp and Zig, builds mlx + mlx-c with NAX kernels asserted, compiles the Swift app and the Zig server, then bundles and signs. With no signing identity in the environment it signs ad-hoc and skips notarization, so no Apple developer account is needed. Releases are cut by .github/workflows/release.yml.

Server only

git submodule update --init                          # mlx, mlx-c, ds4, opencode2 and the absorbed libraries
./scripts/fetch-zig.sh                               # stages the pinned Zig at .zig-toolchain/
export PATH="$PWD/.zig-toolchain:$PATH"
./scripts/fetch-llama.sh && ./scripts/build-mlx.sh   # once, and again on a pin bump
zig build -Doptimize=ReleaseFast                     # always ReleaseFast; Debug is 2-4x slower

Linux and Windows (NVIDIA)

Every release attaches mlx-serve-linux-x64-cuda13.tar.gz (RTX 20 to 50 series) and mlx-serve-linux-arm64-cuda13.tar.gz (GH200, Jetson Thor, DGX Spark). They need an NVIDIA driver 580 or newer, the CUDA 13 toolkit, cuDNN 9, OpenBLAS/LAPACKE, libwebp and the Avahi dns_sd compat library. Unpack into an empty folder (the tarball has no top-level directory) and run zig-out/bin/mlx-serve; it finds its libraries next to itself.

To build on Linux, run ./scripts/build-linux.sh from a fresh checkout. On Windows, powershell -File scripts\build-windows.ps1 builds mlx-serve.exe into dist\mlx-serve-windows-x64.zip; it needs the Visual Studio 2022 C++ tools, CMake, Ninja, Git, the CUDA 13.0 toolkit and cuDNN 9, and running it needs an NVIDIA driver with CUDA 13 and cuDNN 9. Kernels, per-device defaults and memory: CUDA.md.

Hermetic tests (Linux too)

The per-step preview encoder (src/sdk/media/preview.zig + src/sdk/media/jpeg.zig + src/sdk/media/latent_rgb.zig) links no MLX and no Homebrew webp, so any machine, a Linux Cloud Agent included, can build and run it with no GPU:

./scripts/fetch-zig.sh
export PATH="$PWD/.zig-toolchain:$PATH"
zig build preview-test

The same step exists on a Mac and builds the same hermetic artifact, but it is not a way to build without a staged mlx: verifyBrewDeps and verifyMlxStage run at configure time for every step, so lib/mlx/ must already be built. On a Mac zig build test also compiles those files as part of the full suite.