Skip to content

Installation

Requirements

  • Python 3.12+
  • clang 20+ (system-wide)

Installing clang

anvil uses clang for JIT compilation and AOT code generation. Version 20 or later is required.

macOS:

brew install llvm

Make sure the Homebrew-installed clang is on your PATH (or set CC/CXX):

export PATH="$(brew --prefix llvm)/bin:$PATH"

Ubuntu/Debian:

# Add LLVM apt repository
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 20

# Ensure clang-20 is the default
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-20 100
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-20 100

CUDA requirements (optional)

For CUDA GPU support:

  • CUDA toolkit 12.0+ with nvcc and nvrtc (typically installed via the CUDA toolkit)
  • A compatible NVIDIA GPU
  • nvidia-smi available on PATH (for automatic architecture detection)

Install from Git

# with uv (recommended)
uv add git+https://github.com/PREDICT-EPFL/anvil.git

# with SSH
uv add git+ssh://git@github.com/PREDICT-EPFL/anvil.git

# with pip
pip install git+https://github.com/PREDICT-EPFL/anvil.git

Note

anvil is not yet published to PyPI. PyPI wheels will be available once the repository is made public.

Verify installation

import anvil as av
import numpy as np

@av.numerical_function("test", 3)
def test(x: av.Tensor) -> av.Tensor:
    return x.square()

print(test(np.array([1.0, 2.0, 3.0])))  # [1. 4. 9.]