2022-04-03 12:19:04 +03:00
|
|
|
# CUDA {#cuda}
|
|
|
|
|
|
|
|
CUDA-only packages are stored in the `cudaPackages` packages set. This set
|
|
|
|
includes the `cudatoolkit`, portions of the toolkit in separate derivations,
|
|
|
|
`cudnn`, `cutensor` and `nccl`.
|
|
|
|
|
|
|
|
A package set is available for each CUDA version, so for example
|
|
|
|
`cudaPackages_11_6`. Within each set is a matching version of the above listed
|
|
|
|
packages. Additionally, other versions of the packages that are packaged and
|
|
|
|
compatible are available as well. For example, there can be a
|
2023-05-24 19:48:20 +03:00
|
|
|
`cudaPackages.cudnn_8_3` package.
|
2022-04-03 12:19:04 +03:00
|
|
|
|
|
|
|
To use one or more CUDA packages in an expression, give the expression a `cudaPackages` parameter, and in case CUDA is optional
|
|
|
|
```nix
|
2023-03-31 16:16:02 +03:00
|
|
|
{ config
|
2023-07-20 17:57:06 +03:00
|
|
|
, cudaSupport ? config.cudaSupport
|
2023-03-31 16:16:02 +03:00
|
|
|
, cudaPackages ? { }
|
|
|
|
, ...
|
|
|
|
}:
|
2022-04-03 12:19:04 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
When using `callPackage`, you can choose to pass in a different variant, e.g.
|
|
|
|
when a different version of the toolkit suffices
|
|
|
|
```nix
|
|
|
|
mypkg = callPackage { cudaPackages = cudaPackages_11_5; }
|
|
|
|
```
|
|
|
|
|
|
|
|
If another version of say `cudnn` or `cutensor` is needed, you can override the
|
|
|
|
package set to make it the default. This guarantees you get a consistent package
|
|
|
|
set.
|
|
|
|
```nix
|
|
|
|
mypkg = let
|
2023-08-14 08:21:26 +03:00
|
|
|
cudaPackages = cudaPackages_11_5.overrideScope (final: prev: {
|
2023-05-24 19:48:20 +03:00
|
|
|
cudnn = prev.cudnn_8_3;
|
2022-04-03 12:19:04 +03:00
|
|
|
}});
|
|
|
|
in callPackage { inherit cudaPackages; };
|
|
|
|
```
|
2022-12-17 09:00:36 +03:00
|
|
|
|
|
|
|
The CUDA NVCC compiler requires flags to determine which hardware you
|
|
|
|
want to target for in terms of SASS (real hardware) or PTX (JIT kernels).
|
|
|
|
|
|
|
|
Nixpkgs tries to target support real architecture defaults based on the
|
|
|
|
CUDA toolkit version with PTX support for future hardware. Experienced
|
2022-12-18 02:21:48 +03:00
|
|
|
users may optimize this configuration for a variety of reasons such as
|
2022-12-17 09:00:36 +03:00
|
|
|
reducing binary size and compile time, supporting legacy hardware, or
|
|
|
|
optimizing for specific hardware.
|
|
|
|
|
|
|
|
You may provide capabilities to add support or reduce binary size through
|
|
|
|
`config` using `cudaCapabilities = [ "6.0" "7.0" ];` and
|
|
|
|
`cudaForwardCompat = true;` if you want PTX support for future hardware.
|
|
|
|
|
|
|
|
Please consult [GPUs supported](https://en.wikipedia.org/wiki/CUDA#GPUs_supported)
|
|
|
|
for your specific card(s).
|
|
|
|
|
|
|
|
Library maintainers should consult [NVCC Docs](https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/)
|
|
|
|
and release notes for their software package.
|