Skip to content

Repository files navigation

CUDA Toolkit

CI

image

Project Overview

This repository provides the CUDA toolkit (CUDA, cuDNN, and related redistributions) hermetically using Bazel.

This project has similarities with rules_cuda or rules_ml_toolchain except that it provides only the CUDA toolkit without any toolchain definitions or usage assumptions.

It is meant to be consumed by other Bazel projects, notably rulesets and toolchains.

Supported versions

Supported versions are defined in:

  • cuda/cuda_redist_versions.json
  • cudnn/cudnn_redist_versions.json
  • nvshmem/nvshmem_redist_versions.json
  • nccl/nccl_redist_versions.json (generated from NVIDIA's official NCCL archive index with bazel run //tools/nccl:update_redists)

Supported platforms

CUDA components are typically published for these platforms:

  • linux-x86_64
  • linux-sbsa

This module exposes each component through proxy subpackages:

  • @cuda//<component>

These proxy targets are platform-aware and resolve to the correct concrete package for the active Bazel configuration.

For example, @cuda//nvcc:ptxas used from an attribute with cfg = "exec" resolves automatically to the appropriate execution-platform binary.

Recommended usage

Example MODULE.bazel setup:

cuda_ext = use_extension("@cuda_toolkit//extensions:cuda.bzl", "cuda")

cuda_ext.configure(
    name = "cuda",
    default_package_metadata = ["//:cuda_package_metadata"],
)

cuda_ext.redist(
    name = "cuda_12_9_1",
    version = "12.9.1",
    cudnn_version = "8.9.7",
    nvshmem_version = "3.3.24",
    nccl_version = "2.30.7",
)

use_repo(cuda_ext, "cuda")

Notes

  • CUDA versions are registered explicitly with cuda_ext.redist(...).
  • cuda_ext.configure(...) can set the global proxy repository's name and optionally apply default_package_metadata to every generated repository through REPO.bazel.
  • cuDNN, NVSHMEM, and NCCL versions, when used, are pinned on the same cuda_ext.redist(...) tag.
  • The generated NCCL catalog includes every official release from 2.25.1 onward that publishes an archive for a registered CUDA minor version.
  • NCCL archives record their exact build CUDA version and an explicit list of compatible registered CUDA minor versions; unsupported NCCL/CUDA pairs fail during module extension evaluation.
  • CUDA packages under @cuda//<components> are platform-resolving proxies. The selected concrete redistribution is chosen from the current Bazel configuration platform (including exec config).
  • CUDA libraries backed by *_shared_library imports also expose *_interface_library imports and public foo_system wrappers. These targets link through the redistribution's lightweight stub libraries where available (and otherwise through its unversioned .so interface) and mark the runtime library as system-provided, so the matching CUDA libraries must be available in the runtime environment.
  • For local validation on non-Linux hosts, you can force Linux selection with --platforms=//:platform_linux_amd64 or --platforms=//:platform_linux_arm64.

License

This project is licensed under the MIT License.

About

Hermetic CUDA Toolkit using Bazel

Resources

Stars

16 stars

Watchers

3 watching

Forks

Releases

Contributors

Languages