Skip to content

Commit 1b9c962

Browse files
authored
cusparselt: init at 0.7.1 (#390863)
2 parents bc096a7 + 3016de2 commit 1b9c962

File tree

9 files changed

+299
-2
lines changed

9 files changed

+299
-2
lines changed

maintainers/maintainer-list.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21609,6 +21609,12 @@
2160921609
githubId = 529649;
2161021610
name = "Raffael Mancini";
2161121611
};
21612+
sepiabrown = {
21613+
email = "[email protected]";
21614+
github = "sepiabrown";
21615+
githubId = 35622998;
21616+
name = "Suwon Park";
21617+
};
2161221618
seppeljordan = {
2161321619
email = "[email protected]";
2161421620
github = "seppeljordan";

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

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,30 @@
44
fetchFromGitHub,
55
cmake,
66
addDriverRunpath,
7+
autoAddDriverRunpath,
78
cudatoolkit,
89
cutensor,
10+
cusparselt,
11+
cudaPackages,
12+
setupCudaHook,
13+
autoPatchelfHook,
914
}:
1015

1116
let
12-
rev = "5aab680905d853bce0dbad4c488e4f7e9f7b2302";
17+
inherit (cudaPackages)
18+
cuda_cccl
19+
cuda_cudart
20+
cuda_nvcc
21+
libcusparse
22+
cudaAtLeast
23+
cudaOlder
24+
;
25+
rev = "e57b9c483c5384b7b97b7d129457e5a9bdcdb5e1";
1326
src = fetchFromGitHub {
1427
owner = "NVIDIA";
1528
repo = "CUDALibrarySamples";
1629
inherit rev;
17-
sha256 = "0gwgbkq05ygrfgg5hk07lmap7n7ampxv0ha1axrv8qb748ph81xs";
30+
sha256 = "0g17afsmb8am0darxchqgjz1lmkaihmnn7k1x4ahg5gllcmw8k3l";
1831
};
1932
commonAttrs = {
2033
version = lib.strings.substring 0 7 rev + "-" + lib.versions.majorMinor cudatoolkit.version;
@@ -83,4 +96,50 @@ in
8396
CUTENSOR_ROOT = cutensor;
8497
}
8598
);
99+
100+
cusparselt = backendStdenv.mkDerivation (
101+
commonAttrs
102+
// {
103+
pname = "cuda-library-samples-cusparselt";
104+
105+
src = "${src}/cuSPARSELt";
106+
107+
sourceRoot = "cuSPARSELt/matmul";
108+
109+
buildInputs = lib.optionals (cudaOlder "11.4") [ cudatoolkit ];
110+
111+
nativeBuildInputs =
112+
[
113+
cmake
114+
addDriverRunpath
115+
(lib.getDev cusparselt)
116+
(lib.getDev libcusparse)
117+
]
118+
++ lib.optionals (cudaOlder "11.4") [ cudatoolkit ]
119+
++ lib.optionals (cudaAtLeast "11.4") [
120+
cuda_nvcc
121+
(lib.getDev cuda_cudart) # <cuda_runtime_api.h>
122+
]
123+
++ lib.optionals (cudaAtLeast "12.0") [
124+
cuda_cccl # <nv/target>
125+
];
126+
127+
postPatch = ''
128+
substituteInPlace CMakeLists.txt \
129+
--replace-fail "''${CUSPARSELT_ROOT}/lib64/libcusparseLt.so" "${lib.getLib cusparselt}/lib/libcusparseLt.so" \
130+
--replace-fail "''${CUSPARSELT_ROOT}/lib64/libcusparseLt_static.a" "${lib.getStatic cusparselt}/lib/libcusparseLt_static.a"
131+
'';
132+
133+
installPhase = ''
134+
runHook preInstall
135+
mkdir -p $out/bin
136+
cp matmul_example $out/bin/
137+
cp matmul_example_static $out/bin/
138+
runHook postInstall
139+
'';
140+
141+
CUDA_TOOLKIT_PATH = lib.getLib cudatoolkit;
142+
CUSPARSELT_PATH = lib.getLib cusparselt;
143+
}
144+
);
86145
}
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Support matrix can be found at
2+
# https://docs.nvidia.com/deeplearning/cudnn/archives/cudnn-880/support-matrix/index.html
3+
{
4+
lib,
5+
stdenv,
6+
cudaVersion,
7+
flags,
8+
mkVersionedPackageName,
9+
}:
10+
let
11+
inherit (lib)
12+
attrsets
13+
lists
14+
modules
15+
versions
16+
strings
17+
trivial
18+
;
19+
20+
inherit (stdenv) hostPlatform;
21+
22+
redistName = "cusparselt";
23+
pname = "libcusparse_lt";
24+
25+
cusparseltVersions = [
26+
"0.7.1"
27+
];
28+
29+
# Manifests :: { redistrib, feature }
30+
31+
# Each release of cusparselt gets mapped to an evaluated module for that release.
32+
# From there, we can get the min/max CUDA versions supported by that release.
33+
# listOfManifests :: List Manifests
34+
listOfManifests =
35+
let
36+
configEvaluator =
37+
fullCusparseltVersion:
38+
modules.evalModules {
39+
modules = [
40+
../modules
41+
# We need to nest the manifests in a config.cusparselt.manifests attribute so the
42+
# module system can evaluate them.
43+
{
44+
cusparselt.manifests = {
45+
redistrib = trivial.importJSON (./manifests + "/redistrib_${fullCusparseltVersion}.json");
46+
feature = trivial.importJSON (./manifests + "/feature_${fullCusparseltVersion}.json");
47+
};
48+
}
49+
];
50+
};
51+
# Un-nest the manifests attribute set.
52+
releaseGrabber = evaluatedModules: evaluatedModules.config.cusparselt.manifests;
53+
in
54+
lists.map (trivial.flip trivial.pipe [
55+
configEvaluator
56+
releaseGrabber
57+
]) cusparseltVersions;
58+
59+
# Our cudaVersion tells us which version of CUDA we're building against.
60+
# The subdirectories in lib/ tell us which versions of CUDA are supported.
61+
# Typically the names will look like this:
62+
#
63+
# - 10.2
64+
# - 11
65+
# - 11.0
66+
# - 12
67+
68+
# libPath :: String
69+
libPath =
70+
let
71+
cudaMajorMinor = versions.majorMinor cudaVersion;
72+
cudaMajor = versions.major cudaVersion;
73+
in
74+
if cudaMajorMinor == "10.2" then cudaMajorMinor else cudaMajor;
75+
76+
# A release is supported if it has a libPath that matches our CUDA version for our platform.
77+
# LibPath are not constant across the same release -- one platform may support fewer
78+
# CUDA versions than another.
79+
# redistArch :: String
80+
redistArch = flags.getRedistArch hostPlatform.system;
81+
# platformIsSupported :: Manifests -> Boolean
82+
platformIsSupported =
83+
{ feature, redistrib, ... }:
84+
(attrsets.attrByPath [
85+
pname
86+
redistArch
87+
] null feature) != null;
88+
89+
# TODO(@connorbaker): With an auxiliary file keeping track of the CUDA versions each release supports,
90+
# we could filter out releases that don't support our CUDA version.
91+
# However, we don't have that currently, so we make a best-effort to try to build TensorRT with whatever
92+
# libPath corresponds to our CUDA version.
93+
# supportedManifests :: List Manifests
94+
supportedManifests = builtins.filter platformIsSupported listOfManifests;
95+
96+
# Compute versioned attribute name to be used in this package set
97+
# Patch version changes should not break the build, so we only use major and minor
98+
# computeName :: RedistribRelease -> String
99+
computeName = { version, ... }: mkVersionedPackageName redistName version;
100+
in
101+
final: _:
102+
let
103+
# buildCusparseltPackage :: Manifests -> AttrSet Derivation
104+
buildCusparseltPackage =
105+
{ redistrib, feature }:
106+
let
107+
drv = final.callPackage ../generic-builders/manifest.nix {
108+
inherit pname redistName;
109+
redistribRelease = redistrib.${pname};
110+
featureRelease = feature.${pname};
111+
};
112+
fixedDrv = drv.overrideAttrs (prevAttrs: {
113+
buildInputs =
114+
prevAttrs.buildInputs
115+
++ lists.optionals (strings.versionOlder cudaVersion "11.4") [ final.cudatoolkit ]
116+
++ lists.optionals (strings.versionAtLeast cudaVersion "11.4") (
117+
[ final.libcublas.lib ]
118+
# For some reason, the 1.4.x release of cusparselt requires the cudart library.
119+
++ lists.optionals (strings.hasPrefix "1.4" redistrib.${pname}.version) [ final.cuda_cudart.lib ]
120+
);
121+
meta = prevAttrs.meta // {
122+
description = "cuSPARSELt: A High-Performance CUDA Library for Sparse Matrix-Matrix Multiplication";
123+
homepage = "https://developer.nvidia.com/cusparselt-downloads";
124+
125+
maintainers = prevAttrs.meta.maintainers ++ [ lib.maintainers.sepiabrown ];
126+
license = lib.licenses.unfreeRedistributable // {
127+
shortName = "cuSPARSELt EULA";
128+
fullName = "cuSPARSELt SUPPLEMENT TO SOFTWARE LICENSE AGREEMENT FOR NVIDIA SOFTWARE DEVELOPMENT KITS";
129+
url = "https://docs.nvidia.com/cuda/cusparselt/license.html";
130+
};
131+
};
132+
});
133+
in
134+
attrsets.nameValuePair (computeName redistrib.${pname}) fixedDrv;
135+
136+
extension =
137+
let
138+
nameOfNewest = computeName (lists.last supportedManifests).redistrib.${pname};
139+
drvs = builtins.listToAttrs (lists.map buildCusparseltPackage supportedManifests);
140+
containsDefault = attrsets.optionalAttrs (drvs != { }) { cusparselt = drvs.${nameOfNewest}; };
141+
in
142+
drvs // containsDefault;
143+
in
144+
extension
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"libcusparse_lt": {
3+
"linux-aarch64": {
4+
"outputs": {
5+
"bin": false,
6+
"dev": true,
7+
"doc": false,
8+
"lib": true,
9+
"sample": false,
10+
"static": true
11+
}
12+
},
13+
"linux-sbsa": {
14+
"outputs": {
15+
"bin": false,
16+
"dev": true,
17+
"doc": false,
18+
"lib": true,
19+
"sample": false,
20+
"static": true
21+
}
22+
},
23+
"linux-x86_64": {
24+
"outputs": {
25+
"bin": false,
26+
"dev": true,
27+
"doc": false,
28+
"lib": true,
29+
"sample": false,
30+
"static": true
31+
}
32+
},
33+
"windows-x86_64": {
34+
"outputs": {
35+
"bin": false,
36+
"dev": true,
37+
"doc": false,
38+
"lib": false,
39+
"sample": false,
40+
"static": false
41+
}
42+
}
43+
}
44+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"release_date": "2025-02-25",
3+
"release_label": "0.7.1",
4+
"release_product": "cusparselt",
5+
"libcusparse_lt": {
6+
"name": "NVIDIA cuSPARSELt",
7+
"license": "cuSPARSELt",
8+
"license_path": "libcusparse_lt/LICENSE.txt",
9+
"version": "0.7.1.0",
10+
"linux-x86_64": {
11+
"relative_path": "libcusparse_lt/linux-x86_64/libcusparse_lt-linux-x86_64-0.7.1.0-archive.tar.xz",
12+
"sha256": "a0d885837887c73e466a31b4e86aaae2b7d0cc9c5de0d40921dbe2a15dbd6a88",
13+
"md5": "b2e5f3c9b9d69e1e0b55b16de33fdc6e",
14+
"size": "353151840"
15+
},
16+
"linux-sbsa": {
17+
"relative_path": "libcusparse_lt/linux-sbsa/libcusparse_lt-linux-sbsa-0.7.1.0-archive.tar.xz",
18+
"sha256": "4a131d0a54728e53ba536b50bb65380603456f1656e7df8ee52e285618a0b57c",
19+
"md5": "612a712c7da6e801ee773687e99af87e",
20+
"size": "352406784"
21+
},
22+
"windows-x86_64": {
23+
"relative_path": "libcusparse_lt/windows-x86_64/libcusparse_lt-windows-x86_64-0.7.1.0-archive.zip",
24+
"sha256": "004bcb1b700c24ca8d60a8ddd2124640f61138a6c29914d2afaa0bfa0d0e3cf2",
25+
"md5": "a1d8df8dc8ff4b3bd0e859f992f8f392",
26+
"size": "268594665"
27+
},
28+
"linux-aarch64": {
29+
"relative_path": "libcusparse_lt/linux-aarch64/libcusparse_lt-linux-aarch64-0.7.1.0-archive.tar.xz",
30+
"sha256": "d3b0a660fd552e0bd9a4491b15299d968674833483d5f164cfea35e70646136c",
31+
"md5": "54e3f3b28c94118991ce54ec38f531fb",
32+
"size": "5494380"
33+
}
34+
}
35+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{ options, ... }:
2+
{
3+
options.cusparselt.manifests = options.generic.manifests;
4+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Always after generic
55
./cuda
66
./cudnn
7+
./cusparselt
78
./cutensor
89
./tensorrt
910
];

pkgs/top-level/cuda-packages.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ let
148148
(callPackage ../development/cuda-modules/cutensor/extension.nix {
149149
inherit cudaVersion flags mkVersionedPackageName;
150150
})
151+
(callPackage ../development/cuda-modules/cusparselt/extension.nix {
152+
inherit cudaVersion flags mkVersionedPackageName;
153+
})
151154
(callPackage ../development/cuda-modules/generic-builders/multiplex.nix {
152155
inherit cudaVersion flags mkVersionedPackageName;
153156
pname = "tensorrt";

pkgs/top-level/release-cuda.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ let
2323
|| builtins.elem license.shortName [
2424
"CUDA EULA"
2525
"cuDNN EULA"
26+
"cuSPARSELt EULA"
2627
"cuTENSOR EULA"
2728
"NVidia OptiX EULA"
2829
]

0 commit comments

Comments
 (0)