Skip to content

Build from source

These steps build gravity on Linux and macOS. They are the same commands gravity's CI runs.

git clone https://github.com/astro-weights/gravity
cd gravity

Linux (CPU):

cmake -B build -DGGML_NATIVE=OFF -DLLAMA_USE_PREBUILT_UI=OFF
cmake --build build --config Release -j "$(nproc)"

macOS on Apple silicon (Metal is on by default; -DGGML_METAL=ON is what CI sets):

cmake -B build -DGGML_NATIVE=OFF -DGGML_METAL=ON -DLLAMA_USE_PREBUILT_UI=OFF
cmake --build build --config Release -j "$(sysctl -n hw.ncpu)"

Linux with an NVIDIA GPU (needs the CUDA toolkit; CI compiles this with CUDA 12.6 but has no GPU to run it):

cmake -B build -DGGML_NATIVE=OFF -DGGML_CUDA=ON -DLLAMA_USE_PREBUILT_UI=OFF
cmake --build build --config Release -j "$(nproc)"

If nvcc rejects your gcc (CUDA toolkit and host compiler versions do not match, common on clusters with module-loaded gcc), point nvcc at a supported one. Delete build/ first if a failed run left one, because CMake keeps the compiler it found first:

CUDAHOSTCXX=/usr/bin/g++ cmake -B build -DGGML_NATIVE=OFF -DGGML_CUDA=ON -DLLAMA_USE_PREBUILT_UI=OFF

The binaries are build/bin/llama-server and build/bin/llama-cli. A source build has no gravity command: where the docs say gravity serve, run build/bin/llama-server, and for gravity cli, build/bin/llama-cli. For more CUDA options and for Vulkan, HIP and other backends, see docs/build.md. -DLLAMA_USE_PREBUILT_UI=OFF skips the web UI download, so the server has no web UI.