Skip to content

Commit 7109c07

Browse files
authored
tree-wide: use named CUDA versions and CUDA version utilities (#405664)
2 parents 69ca705 + bf766a2 commit 7109c07

File tree

27 files changed

+113
-119
lines changed

27 files changed

+113
-119
lines changed

pkgs/by-name/ca/catboost/package.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ stdenv.mkDerivation (finalAttrs: {
4545
shopt -s globstar
4646
for cmakelists in **/CMakeLists.*; do
4747
sed -i "s/OpenSSL::OpenSSL/OpenSSL::SSL/g" $cmakelists
48-
${lib.optionalString (lib.versionOlder cudaPackages.cudaVersion "11.8") ''
48+
${lib.optionalString (cudaPackages.cudaOlder "11.8") ''
4949
sed -i 's/-gencode=arch=compute_89,code=sm_89//g' $cmakelists
5050
sed -i 's/-gencode=arch=compute_90,code=sm_90//g' $cmakelists
5151
''}

pkgs/by-name/ti/tiny-cuda-nn/package.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
}:
1414
let
1515
inherit (lib) lists strings;
16-
inherit (cudaPackages) backendStdenv cudaVersion flags;
16+
inherit (cudaPackages) backendStdenv cudaAtLeast flags;
1717

1818
cuda-common-redist = with cudaPackages; [
1919
(lib.getDev cuda_cudart) # cuda_runtime.h
@@ -62,7 +62,7 @@ stdenv.mkDerivation (finalAttrs: {
6262

6363
# Remove this once a release is made with
6464
# https://github.com/NVlabs/tiny-cuda-nn/commit/78a14fe8c292a69f54e6d0d47a09f52b777127e1
65-
postPatch = lib.optionals (strings.versionAtLeast cudaVersion "11.0") ''
65+
postPatch = lib.optionals (cudaAtLeast "11.0") ''
6666
substituteInPlace bindings/torch/setup.py --replace-fail \
6767
"-std=c++14" "-std=c++17"
6868
'';
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# Packages which have been deprecated or removed from cudaPackages
2-
final: prev:
2+
final: _:
33
let
4-
inherit (prev.lib) warn;
5-
inherit (builtins) mapAttrs;
6-
74
mkRenamed =
85
oldName:
96
{ path, package }:
10-
warn "cudaPackages.${oldName} is deprecated, use ${path} instead" package;
7+
final.lib.warn "cudaPackages.${oldName} is deprecated, use ${path} instead" package;
118
in
12-
mapAttrs mkRenamed {
9+
builtins.mapAttrs mkRenamed {
1310
# A comment to prevent empty { } from collapsing into a single line
11+
12+
cudaVersion = {
13+
path = "cudaPackages.cudaMajorMinorVersion";
14+
package = final.cudaMajorMinorVersion;
15+
};
1416
}

pkgs/development/cuda-modules/cuda-samples/extension.nix

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
cudaVersion,
2+
cudaMajorMinorVersion,
33
lib,
44
stdenv,
55
}:
@@ -27,7 +27,7 @@ let
2727

2828
# Samples are built around the CUDA Toolkit, which is not available for
2929
# aarch64. Check for both CUDA version and platform.
30-
cudaVersionIsSupported = cudaVersionToHash ? ${cudaVersion};
30+
cudaVersionIsSupported = cudaVersionToHash ? ${cudaMajorMinorVersion};
3131
platformIsSupported = hostPlatform.isx86_64;
3232
isSupported = cudaVersionIsSupported && platformIsSupported;
3333

@@ -36,8 +36,7 @@ let
3636
final: _:
3737
lib.attrsets.optionalAttrs isSupported {
3838
cuda-samples = final.callPackage ./generic.nix {
39-
inherit cudaVersion;
40-
hash = cudaVersionToHash.${cudaVersion};
39+
hash = cudaVersionToHash.${cudaMajorMinorVersion};
4140
};
4241
};
4342
in

pkgs/development/cuda-modules/cuda-samples/generic.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
backendStdenv,
44
cmake,
55
cudatoolkit,
6-
cudaVersion,
6+
cudaMajorMinorVersion,
77
fetchFromGitHub,
88
fetchpatch,
99
freeimage,
@@ -20,7 +20,7 @@ backendStdenv.mkDerivation (finalAttrs: {
2020
strictDeps = true;
2121

2222
pname = "cuda-samples";
23-
version = cudaVersion;
23+
version = cudaMajorMinorVersion;
2424

2525
src = fetchFromGitHub {
2626
owner = "NVIDIA";

pkgs/development/cuda-modules/cuda/extension.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ cudaVersion, lib }:
1+
{ cudaMajorMinorVersion, lib }:
22
let
33
inherit (lib) attrsets modules trivial;
44
redistName = "cuda";
@@ -23,10 +23,10 @@ let
2323
};
2424

2525
# Check if the current CUDA version is supported.
26-
cudaVersionMappingExists = builtins.hasAttr cudaVersion cudaVersionMap;
26+
cudaVersionMappingExists = builtins.hasAttr cudaMajorMinorVersion cudaVersionMap;
2727

2828
# fullCudaVersion : String
29-
fullCudaVersion = cudaVersionMap.${cudaVersion};
29+
fullCudaVersion = cudaVersionMap.${cudaMajorMinorVersion};
3030

3131
evaluatedModules = modules.evalModules {
3232
modules = [

pkgs/development/cuda-modules/cudatoolkit/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
cudaVersion,
2+
cudaMajorMinorVersion,
33
runPatches ? [ ],
44
autoPatchelfHook,
55
autoAddDriverRunpath,
@@ -54,7 +54,7 @@
5454
let
5555
# Version info for the classic cudatoolkit packages that contain everything that is in redist.
5656
releases = builtins.import ./releases.nix;
57-
release = releases.${cudaVersion};
57+
release = releases.${cudaMajorMinorVersion};
5858
in
5959

6060
backendStdenv.mkDerivation rec {

pkgs/development/cuda-modules/cudatoolkit/redist-wrapper.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
backendStdenv,
55
cudaOlder,
66
cudatoolkit-legacy-runfile,
7-
cudaVersion,
7+
cudaMajorMinorVersion,
88
cuda_cccl ? null,
99
cuda_cudart ? null,
1010
cuda_cuobjdump ? null,
@@ -66,8 +66,8 @@ if cudaOlder "11.4" then
6666
cudatoolkit-legacy-runfile
6767
else
6868
symlinkJoin rec {
69-
name = "cuda-merged-${cudaVersion}";
70-
version = cudaVersion;
69+
name = "cuda-merged-${cudaMajorMinorVersion}";
70+
version = cudaMajorMinorVersion;
7171

7272
paths = builtins.concatMap getAllOutputs allPackages;
7373

pkgs/development/cuda-modules/cusparselt/extension.nix

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
lib,
55
stdenv,
6-
cudaVersion,
6+
cudaMajorMinorVersion,
77
flags,
88
mkVersionedPackageName,
99
}:
@@ -54,15 +54,6 @@ let
5454
releaseGrabber
5555
]) cusparseltVersions;
5656

57-
# Our cudaVersion tells us which version of CUDA we're building against.
58-
# The subdirectories in lib/ tell us which versions of CUDA are supported.
59-
# Typically the names will look like this:
60-
#
61-
# - 10.2
62-
# - 11
63-
# - 11.0
64-
# - 12
65-
6657
# A release is supported if it has a libPath that matches our CUDA version for our platform.
6758
# LibPath are not constant across the same release -- one platform may support fewer
6859
# CUDA versions than another.

pkgs/development/cuda-modules/cutensor/extension.nix

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# - Instead of providing different releases for each version of CUDA, CuTensor has multiple subdirectories in `lib`
1414
# -- one for each version of CUDA.
1515
{
16-
cudaVersion,
16+
cudaMajorMinorVersion,
1717
flags,
1818
lib,
1919
mkVersionedPackageName,
@@ -73,7 +73,7 @@ let
7373
releaseGrabber
7474
]) cutensorVersions;
7575

76-
# Our cudaVersion tells us which version of CUDA we're building against.
76+
# Our cudaMajorMinorVersion tells us which version of CUDA we're building against.
7777
# The subdirectories in lib/ tell us which versions of CUDA are supported.
7878
# Typically the names will look like this:
7979
#
@@ -85,10 +85,9 @@ let
8585
# libPath :: String
8686
libPath =
8787
let
88-
cudaMajorMinor = versions.majorMinor cudaVersion;
89-
cudaMajor = versions.major cudaVersion;
88+
cudaMajorVersion = versions.major cudaMajorMinorVersion;
9089
in
91-
if cudaMajorMinor == "10.2" then cudaMajorMinor else cudaMajor;
90+
if cudaMajorMinorVersion == "10.2" then cudaMajorMinorVersion else cudaMajorVersion;
9291

9392
# A release is supported if it has a libPath that matches our CUDA version for our platform.
9493
# LibPath are not constant across the same release -- one platform may support fewer

0 commit comments

Comments
 (0)