···11-# cuda-modules
11+# Cuda modules
2233> [!NOTE]
44-> This document is meant to help CUDA maintainers understand the structure of the CUDA packages in Nixpkgs. It is not meant to be a user-facing document.
44+> This document is meant to help CUDA maintainers understand the structure of
55+> the CUDA packages in Nixpkgs. It is not meant to be a user-facing document.
56> For a user-facing document, see [the CUDA section of the manual](../../../doc/languages-frameworks/cuda.section.md).
6777-The files in this directory are added (in some way) to the `cudaPackages` package set by [cuda-packages.nix](../../top-level/cuda-packages.nix).
88+The files in this directory are added (in some way) to the `cudaPackages`
99+package set by [cuda-packages.nix](../../top-level/cuda-packages.nix).
810911## Top-level files
10121111-Top-level nix files are included in the initial creation of the `cudaPackages` scope. These are typically required for the creation of the finalized `cudaPackages` scope:
1313+Top-level nix files are included in the initial creation of the `cudaPackages`
1414+scope. These are typically required for the creation of the finalized
1515+`cudaPackages` scope:
12161317- `backend-stdenv.nix`: Standard environment for CUDA packages.
1418- `flags.nix`: Flags set, or consumed by, NVCC in order to build packages.
1519- `gpus.nix`: A list of supported NVIDIA GPUs.
1616-- `nvcc-compatibilities.nix`: NVCC releases and the version range of GCC/Clang they support.
2020+- `nvcc-compatibilities.nix`: NVCC releases and the version range of GCC/Clang
2121+ they support.
17221823## Top-level directories
19242025- `cuda`: CUDA redistributables! Provides extension to `cudaPackages` scope.
2121-- `cudatoolkit`: monolothic CUDA Toolkit run-file installer. Provides extension to `cudaPackages` scope.
2626+- `cudatoolkit`: monolothic CUDA Toolkit run-file installer. Provides extension
2727+ to `cudaPackages` scope.
2228- `cudnn`: NVIDIA cuDNN library.
2329- `cutensor`: NVIDIA cuTENSOR library.
2430- `generic-builders`:
2525- - Contains a builder `manifest.nix` which operates on the `Manifest` type defined in `modules/generic/manifests`. Most packages are built using this builder.
2626- - Contains a builder `multiplex.nix` which leverages the Manifest builder. In short, the Multiplex builder adds multiple versions of a single package to single instance of the CUDA Packages package set. It is used primarily for packages like `cudnn` and `cutensor`.
2727-- `modules`: Nixpkgs modules to check the shape and content of CUDA redistributable and feature manifests. These modules additionally use shims provided by some CUDA packages to allow them to re-use the `genericManifestBuilder`, even if they don't have manifest files of their own. `cudnn` and `tensorrt` are examples of packages which provide such shims. These modules are further described in the [Modules](./modules/README.md) documentation.
3131+ - Contains a builder `manifest.nix` which operates on the `Manifest` type
3232+ defined in `modules/generic/manifests`. Most packages are built using this
3333+ builder.
3434+ - Contains a builder `multiplex.nix` which leverages the Manifest builder. In
3535+ short, the Multiplex builder adds multiple versions of a single package to
3636+ single instance of the CUDA Packages package set. It is used primarily for
3737+ packages like `cudnn` and `cutensor`.
3838+- `modules`: Nixpkgs modules to check the shape and content of CUDA
3939+ redistributable and feature manifests. These modules additionally use shims
4040+ provided by some CUDA packages to allow them to re-use the
4141+ `genericManifestBuilder`, even if they don't have manifest files of their
4242+ own. `cudnn` and `tensorrt` are examples of packages which provide such
4343+ shims. These modules are further described in the
4444+ [Modules](./modules/README.md) documentation.
2845- `nccl`: NVIDIA NCCL library.
2946- `nccl-tests`: NVIDIA NCCL tests.
3047- `saxpy`: Example CMake project that uses CUDA.
+38-9
pkgs/development/cuda-modules/modules/README.md
···11# Modules
2233-Modules as they are used in `modules` exist primarily to check the shape and content of CUDA redistributable and feature manifests. They are ultimately meant to reduce the repetitive nature of repackaging CUDA redistributables.
33+Modules as they are used in `modules` exist primarily to check the shape and
44+content of CUDA redistributable and feature manifests. They are ultimately meant
55+to reduce the repetitive nature of repackaging CUDA redistributables.
4655-Building most redistributables follows a pattern of a manifest indicating which packages are available at a location, their versions, and their hashes. To avoid creating builders for each and every derivation, modules serve as a way for us to use a single `genericManifestBuilder` to build all redistributables.
77+Building most redistributables follows a pattern of a manifest indicating which
88+packages are available at a location, their versions, and their hashes. To avoid
99+creating builders for each and every derivation, modules serve as a way for us
1010+to use a single `genericManifestBuilder` to build all redistributables.
611712## `generic`
81399-The modules in `generic` are reusable components meant to check the shape and content of NVIDIA's CUDA redistributable manifests, our feature manifests (which are derived from NVIDIA's manifests), or hand-crafted Nix expressions describing available packages. They are used by the `genericManifestBuilder` to build CUDA redistributables.
1414+The modules in `generic` are reusable components meant to check the shape and
1515+content of NVIDIA's CUDA redistributable manifests, our feature manifests (which
1616+are derived from NVIDIA's manifests), or hand-crafted Nix expressions describing
1717+available packages. They are used by the `genericManifestBuilder` to build CUDA
1818+redistributables.
10191111-Generally, each package which relies on manifests or Nix release expressions will create an alias to the relevant generic module. For example, the [module for CUDNN](./cudnn/default.nix) aliases the generic module for release expressions, while the [module for CUDA redistributables](./cuda/default.nix) aliases the generic module for manifests.
2020+Generally, each package which relies on manifests or Nix release expressions
2121+will create an alias to the relevant generic module. For example, the [module
2222+for CUDNN](./cudnn/default.nix) aliases the generic module for release
2323+expressions, while the [module for CUDA redistributables](./cuda/default.nix)
2424+aliases the generic module for manifests.
12251313-Alternatively, additional fields or values may need to be configured to account for the particulars of a package. For example, while the release expressions for [CUDNN](./cudnn/releases.nix) and [TensorRT](./tensorrt/releases.nix) are very close, they differ slightly in the fields they have. The [module for CUDNN](./modules/cudnn/default.nix) is able to use the generic module for release expressions, while the [module for TensorRT](./modules/tensorrt/default.nix) must add additional fields to the generic module.
2626+Alternatively, additional fields or values may need to be configured to account
2727+for the particulars of a package. For example, while the release expressions for
2828+[CUDNN](./cudnn/releases.nix) and [TensorRT](./tensorrt/releases.nix) are very
2929+close, they differ slightly in the fields they have. The [module for
3030+CUDNN](./modules/cudnn/default.nix) is able to use the generic module for
3131+release expressions, while the [module for
3232+TensorRT](./modules/tensorrt/default.nix) must add additional fields to the
3333+generic module.
14341535### `manifests`
16361717-The modules in `generic/manifests` define the structure of NVIDIA's CUDA redistributable manifests and our feature manifests.
3737+The modules in `generic/manifests` define the structure of NVIDIA's CUDA
3838+redistributable manifests and our feature manifests.
18391919-NVIDIA's redistributable manifests are retrieved from their web server, while the feature manifests are produced by [`cuda-redist-find-features`](https://github.com/connorbaker/cuda-redist-find-features).
4040+NVIDIA's redistributable manifests are retrieved from their web server, while
4141+the feature manifests are produced by
4242+[`cuda-redist-find-features`](https://github.com/connorbaker/cuda-redist-find-features).
20432144### `releases`
22452323-The modules in `generic/releases` define the structure of our hand-crafted Nix expressions containing information necessary to download and repackage CUDA redistributables. These expressions are created when NVIDIA-provided manifests are unavailable or otherwise unusable. For example, though CUDNN has manifests, a bug in NVIDIA's CI/CD causes manifests for different versions of CUDA to use the same name, which leads to the manifests overwriting each other.
4646+The modules in `generic/releases` define the structure of our hand-crafted Nix
4747+expressions containing information necessary to download and repackage CUDA
4848+redistributables. These expressions are created when NVIDIA-provided manifests
4949+are unavailable or otherwise unusable. For example, though CUDNN has manifests,
5050+a bug in NVIDIA's CI/CD causes manifests for different versions of CUDA to use
5151+the same name, which leads to the manifests overwriting each other.
24522553### `types`
26542727-The modules in `generic/types` define reusable types used in both `generic/manifests` and `generic/releases`.
5555+The modules in `generic/types` define reusable types used in both
5656+`generic/manifests` and `generic/releases`.