···151 # Refer to comments in the overrides for cuda_nvcc for explanation
152 # CUDA_TOOLKIT_ROOT_DIR is legacy,
153 # Cf. https://cmake.org/cmake/help/latest/module/FindCUDA.html#input-variables
0000154 ''
155 mkdir -p $out/nix-support
156 cat <<EOF >> $out/nix-support/setup-hook
···160 if [ -z "\''${CUDAHOSTCXX-}" ]; then
161 export CUDAHOSTCXX=${backendStdenv.cc}/bin;
162 fi
163- export NVCC_PREPEND_FLAGS+=' --compiler-bindir=${backendStdenv.cc}/bin'
164 EOF
165166 # Move some libraries to the lib output so that programs that
···151 # Refer to comments in the overrides for cuda_nvcc for explanation
152 # CUDA_TOOLKIT_ROOT_DIR is legacy,
153 # Cf. https://cmake.org/cmake/help/latest/module/FindCUDA.html#input-variables
154+ # NOTE: We unconditionally set -Xfatbin=-compress-all, which reduces the size of the compiled
155+ # binaries. If binaries grow over 2GB, they will fail to link. This is a problem for us, as
156+ # the default set of CUDA capabilities we build can regularly cause this to occur (for
157+ # example, with Magma).
158 ''
159 mkdir -p $out/nix-support
160 cat <<EOF >> $out/nix-support/setup-hook
···164 if [ -z "\''${CUDAHOSTCXX-}" ]; then
165 export CUDAHOSTCXX=${backendStdenv.cc}/bin;
166 fi
167+ export NVCC_PREPEND_FLAGS+=' --compiler-bindir=${backendStdenv.cc}/bin -Xfatbin=-compress-all'
168 EOF
169170 # Move some libraries to the lib output so that programs that
+23-9
pkgs/development/compilers/cudatoolkit/flags.nix
···4}:
56# Type aliases
7-# Gpu = {
8-# archName: String, # e.g., "Hopper"
9-# computeCapability: String, # e.g., "9.0"
10-# minCudaVersion: String, # e.g., "11.8"
11-# maxCudaVersion: String, # e.g., "12.0"
12-# }
1314let
15 inherit (lib) attrsets lists strings trivial versions;
···34 # gpus :: List Gpu
35 gpus = builtins.import ./gpus.nix;
3637- # isVersionIn :: Gpu -> Bool
38 isSupported = gpu:
39 let
40 inherit (gpu) minCudaVersion maxCudaVersion;
41 lowerBoundSatisfied = strings.versionAtLeast cudaVersion minCudaVersion;
42- upperBoundSatisfied = !(strings.versionOlder maxCudaVersion cudaVersion);
043 in
44 lowerBoundSatisfied && upperBoundSatisfied;
4500000000046 # supportedGpus :: List Gpu
47 # GPUs which are supported by the provided CUDA version.
48 supportedGpus = builtins.filter isSupported gpus;
49000050 # supportedCapabilities :: List Capability
51 supportedCapabilities = lists.map (gpu: gpu.computeCapability) supportedGpus;
00005253 # cudaArchNameToVersions :: AttrSet String (List String)
54 # Maps the name of a GPU architecture to different versions of that architecture.
···151 # dropDot :: String -> String
152 inherit dropDot;
153} // formatCapabilities {
154- cudaCapabilities = config.cudaCapabilities or supportedCapabilities;
155 enableForwardCompat = config.cudaForwardCompat or true;
156}
···4}:
56# Type aliases
7+# Gpu :: AttrSet
8+# - See the documentation in ./gpus.nix.
0000910let
11 inherit (lib) attrsets lists strings trivial versions;
···30 # gpus :: List Gpu
31 gpus = builtins.import ./gpus.nix;
3233+ # isSupported :: Gpu -> Bool
34 isSupported = gpu:
35 let
36 inherit (gpu) minCudaVersion maxCudaVersion;
37 lowerBoundSatisfied = strings.versionAtLeast cudaVersion minCudaVersion;
38+ upperBoundSatisfied = (maxCudaVersion == null)
39+ || !(strings.versionOlder maxCudaVersion cudaVersion);
40 in
41 lowerBoundSatisfied && upperBoundSatisfied;
4243+ # isDefault :: Gpu -> Bool
44+ isDefault = gpu:
45+ let
46+ inherit (gpu) dontDefaultAfter;
47+ newGpu = dontDefaultAfter == null;
48+ recentGpu = newGpu || strings.versionAtLeast dontDefaultAfter cudaVersion;
49+ in
50+ recentGpu;
51+52 # supportedGpus :: List Gpu
53 # GPUs which are supported by the provided CUDA version.
54 supportedGpus = builtins.filter isSupported gpus;
5556+ # defaultGpus :: List Gpu
57+ # GPUs which are supported by the provided CUDA version and we want to build for by default.
58+ defaultGpus = builtins.filter isDefault supportedGpus;
59+60 # supportedCapabilities :: List Capability
61 supportedCapabilities = lists.map (gpu: gpu.computeCapability) supportedGpus;
62+63+ # defaultCapabilities :: List Capability
64+ # The default capabilities to target, if not overridden by the user.
65+ defaultCapabilities = lists.map (gpu: gpu.computeCapability) defaultGpus;
6667 # cudaArchNameToVersions :: AttrSet String (List String)
68 # Maps the name of a GPU architecture to different versions of that architecture.
···165 # dropDot :: String -> String
166 inherit dropDot;
167} // formatCapabilities {
168+ cudaCapabilities = config.cudaCapabilities or defaultCapabilities;
169 enableForwardCompat = config.cudaForwardCompat or true;
170}
···41 # uses the last --compiler-bindir it gets on the command line.
42 # FIXME: this results in "incompatible redefinition" warnings.
43 # https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#compiler-bindir-directory-ccbin
000044 postInstall = (oldAttrs.postInstall or "") + ''
45 mkdir -p $out/nix-support
46 cat <<EOF >> $out/nix-support/setup-hook
···49 if [ -z "\''${CUDAHOSTCXX-}" ]; then
50 export CUDAHOSTCXX=${cc}/bin;
51 fi
52- export NVCC_PREPEND_FLAGS+=' --compiler-bindir=${cc}/bin'
53 EOF
54 '';
55 });
···41 # uses the last --compiler-bindir it gets on the command line.
42 # FIXME: this results in "incompatible redefinition" warnings.
43 # https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#compiler-bindir-directory-ccbin
44+ # NOTE: We unconditionally set -Xfatbin=-compress-all, which reduces the size of the
45+ # compiled binaries. If binaries grow over 2GB, they will fail to link. This is a problem
46+ # for us, as the default set of CUDA capabilities we build can regularly cause this to
47+ # occur (for example, with Magma).
48 postInstall = (oldAttrs.postInstall or "") + ''
49 mkdir -p $out/nix-support
50 cat <<EOF >> $out/nix-support/setup-hook
···53 if [ -z "\''${CUDAHOSTCXX-}" ]; then
54 export CUDAHOSTCXX=${cc}/bin;
55 fi
56+ export NVCC_PREPEND_FLAGS+=' --compiler-bindir=${cc}/bin -Xfatbin=-compress-all'
57 EOF
58 '';
59 });