This repository has been archived by the owner on Mar 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
use-cudatoolkit-root.nix
80 lines (67 loc) · 1.53 KB
/
use-cudatoolkit-root.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{ cmake
, cppzmq
, cudaPackages
, glibc
, patchelf
, stdenv
, zeromq
}:
with cudaPackages;
let
cudaPaths = [
cuda_nvcc
cuda_cudart
cuda_nvtx # It seems that CUDA::cudart won't work without this
libcublas # Just to see if we can target_link_libraries
];
CUDAToolkit_ROOT = builtins.concatStringsSep ";" (map lib.getDev cudaPaths);
CUDAToolkit_INCLUDE_DIR = builtins.concatStringsSep ";" (lib.pipe cudaPaths [
(map lib.getDev)
(map (x: "${x}/include"))
]);
in
stdenv.mkDerivation {
pname = "demo";
version = "0.0.1";
src = ./.;
nativeBuildInputs = [
autoAddOpenGLRunpathHook
cmake
cuda_nvcc
];
buildInputs = [
cppzmq
zeromq
];
cmakeFlags = [
"-DCUDAToolkit_ROOT=${CUDAToolkit_ROOT}"
"-DCUDAToolkit_INCLUDE_DIR=${CUDAToolkit_INCLUDE_DIR}"
"-DCMAKE_VERBOSE_MAKEFILE=ON"
"-DCMAKE_MESSAGE_LOG_LEVEL=TRACE"
];
preConfigure = ''
export NVCC_APPEND_FLAGS+=" -L${cuda_cudart}/lib -I${cuda_cudart}/include"
'';
nativeCheckInputs = map lib.getBin [
glibc # ldd
patchelf
];
doInstallCheck = true;
preInstallCheck = ''
echo ldd $(pwd)/demo
ldd $(pwd)/demo
if ldd $out/bin/demo | grep -q "not found"
then
echo patchelf --print-rpath $out/bin/demo
patchelf --print-rpath $out/bin/demo
echo
echo patchelf --print-needed $out/bin/demo
patchelf --print-needed $out/bin/demo
echo
echo ldd $out/bin/demo
ldd $out/bin/demo
# exit 1
fi
'';
passthru = { inherit CUDAToolkit_ROOT; };
}