Skip to content

How to Install Triton

Triton compiles GPU kernels written in Python. PyTorch installs a compatible Triton dependency for supported Linux builds; standalone projects can install it from PyPI.

Prerequisites

  • Linux x86-64 or aarch64 with glibc 2.27 or later for official wheels.
  • CPython 3.10 through 3.14, subject to the chosen PyTorch release’s requirements.
  • NVIDIA GPU with compute capability 8.0 or higher, or a supported AMD GPU with ROCm 6.2 or later. See upstream hardware compatibility.
  • A working accelerator driver and a C compiler for the host launcher generated during kernel compilation.

Official Triton wheels do not target macOS or native Windows. Use a supported Linux GPU environment; WSL2 requires working GPU passthrough. Third-party Windows ports have separate compatibility guarantees.

Keep PyTorch’s Triton dependency

In a uv project, install the intended PyTorch backend using the PyTorch installation guide. CUDA-enabled Linux PyTorch builds declare a compatible triton dependency in their metadata. Keep that constraint rather than independently upgrading Triton.

The exact dependency varies by PyTorch release, backend, and architecture. ROCm builds also use packages from the PyTorch ROCm index, including pytorch-triton-rocm; do not replace that stack with an arbitrary PyPI Triton version. Follow uv’s ROCm source configuration.

Install standalone

If the project does not depend on PyTorch, add Triton directly:

uv add triton

This installs Triton and records its version in uv.lock; it does not install a GPU driver. Adding Triton alone also does not install PyTorch, which the verification script uses to allocate GPU tensors.

For a source build or a custom compiler toolchain, follow the official installation instructions. A supported binary wheel does not require a local CUDA toolkit containing nvcc, but kernel execution still needs the driver and runtime compilation tools supplied by the package and its environment.

Compile and execute a kernel

Use a project with CUDA-enabled PyTorch and its compatible Triton dependency. Save the kernel in a file so Triton can inspect its source:

check_triton.py
import torch
import triton
import triton.language as tl


@triton.jit
def add_kernel(x_ptr, y_ptr, out_ptr, n, BLOCK: tl.constexpr):
    idx = tl.program_id(0) * BLOCK + tl.arange(0, BLOCK)
    mask = idx < n
    x = tl.load(x_ptr + idx, mask=mask)
    y = tl.load(y_ptr + idx, mask=mask)
    tl.store(out_ptr + idx, x + y, mask=mask)


assert torch.cuda.is_available(), 'CUDA is unavailable to PyTorch'
assert torch.version.hip is None, 'This check targets NVIDIA CUDA'
assert torch.cuda.get_device_capability()[0] >= 8
print(triton.__version__, torch.cuda.get_device_name())
x = torch.randn(1024, device='cuda')
y = torch.randn_like(x)
out = torch.empty_like(x)
add_kernel[(1,)](x, y, out, x.numel(), BLOCK=1024)
torch.cuda.synchronize()
assert out.is_cuda
torch.testing.assert_close(out, x + y)
print('Triton CUDA kernel OK')
uv run python check_triton.py

uv run executes the command inside the project’s virtual environment, ensuring all dependencies are installed first. Expect the Triton version and GPU name, followed by Triton CUDA kernel OK. An import check during a GPU-less container build does not compile or execute a GPU kernel.

Fix a failed kernel check

  • Dependency conflict: remove an incompatible explicit Triton pin and let the selected PyTorch build resolve its dependency.
  • No matching wheel: check Python version, architecture, operating system, and glibc. An environment marker for Linux does not make the package run on macOS or Windows.
  • Driver or compiler error: check GPU visibility and the complete compilation error. A working nvidia-smi proves driver visibility, while the kernel check proves Triton execution. Install the missing host compiler if the error names gcc, cc, or compiler discovery.
  • Unsupported architecture: choose supported hardware. A T4’s compute capability 7.5 falls outside the current upstream NVIDIA support contract, even if a kernel happens to compile on an older Triton build.
Last updated on