Skip to content

Commit 44411e3

Browse files
committedMar 18, 2025
cuda-library-samples.cusparselt: fix build
1 parent c3780f4 commit 44411e3

File tree

1 file changed

+66
-2
lines changed
  • pkgs/development/cuda-modules/cuda-library-samples

1 file changed

+66
-2
lines changed
 

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

+66-2
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,55 @@ 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") [
110+
cudatoolkit
111+
];
112+
113+
nativeBuildInputs =
114+
[
115+
cmake
116+
addDriverRunpath
117+
(lib.getDev cusparselt)
118+
(lib.getDev libcusparse)
119+
]
120+
++
121+
lib.optionals (cudaOlder "11.4") [
122+
cudatoolkit
123+
]
124+
++ lib.optionals (cudaAtLeast "11.4") [
125+
cuda_nvcc
126+
(lib.getDev cuda_cudart) # <cuda_runtime_api.h>
127+
]
128+
++ lib.optionals (cudaAtLeast "12.0") [
129+
cuda_cccl # <nv/target>
130+
];
131+
132+
postPatch = ''
133+
substituteInPlace CMakeLists.txt \
134+
--replace-fail "''${CUSPARSELT_ROOT}/lib64/libcusparseLt.so" "${lib.getLib cusparselt}/lib/libcusparseLt.so" \
135+
--replace-fail "''${CUSPARSELT_ROOT}/lib64/libcusparseLt_static.a" "${lib.getStatic cusparselt}/lib/libcusparseLt_static.a"
136+
'';
137+
138+
installPhase = ''
139+
runHook preInstall
140+
mkdir -p $out/bin
141+
cp matmul_example $out/bin/
142+
cp matmul_example_static $out/bin/
143+
runHook postInstall
144+
'';
145+
146+
CUDA_TOOLKIT_PATH = (lib.getLib cudatoolkit);
147+
CUSPARSELT_PATH = (lib.getLib cusparselt);
148+
}
149+
);
86150
}

0 commit comments

Comments
 (0)
Failed to load comments.