2017-10-15 14:44:54 +03:00
|
|
|
{ version
|
|
|
|
, srcName
|
|
|
|
, sha256
|
|
|
|
}:
|
|
|
|
|
2016-11-07 12:07:29 +01:00
|
|
|
{ stdenv
|
2017-09-17 07:07:40 +03:00
|
|
|
, lib
|
2016-11-07 12:07:29 +01:00
|
|
|
, cudatoolkit
|
2018-07-17 22:21:57 -05:00
|
|
|
, fetchurl
|
2019-05-22 18:34:09 +02:00
|
|
|
, addOpenGLRunpath
|
2021-03-09 14:04:39 +09:00
|
|
|
, # The distributed version of CUDNN includes both dynamically liked .so files,
|
|
|
|
# as well as statically linked .a files. However, CUDNN is quite large
|
|
|
|
# (multiple gigabytes), so you can save some space in your nix store by
|
|
|
|
# removing the statically linked libraries if you are not using them.
|
|
|
|
#
|
|
|
|
# Setting this to true removes the statically linked .a files.
|
|
|
|
# Setting this to false keeps these statically linked .a files.
|
|
|
|
removeStatic ? false
|
2016-11-07 12:07:29 +01:00
|
|
|
}:
|
|
|
|
|
2019-08-13 21:52:01 +00:00
|
|
|
stdenv.mkDerivation {
|
2017-10-15 14:44:54 +03:00
|
|
|
name = "cudatoolkit-${cudatoolkit.majorVersion}-cudnn-${version}";
|
2016-11-07 12:07:29 +01:00
|
|
|
|
2017-10-15 14:44:54 +03:00
|
|
|
inherit version;
|
2018-07-17 22:21:57 -05:00
|
|
|
src = fetchurl {
|
|
|
|
# URL from NVIDIA docker containers: https://gitlab.com/nvidia/cuda/blob/centos7/7.0/runtime/cudnn4/Dockerfile
|
|
|
|
url = "https://developer.download.nvidia.com/compute/redist/cudnn/v${version}/${srcName}";
|
2017-10-15 14:44:54 +03:00
|
|
|
inherit sha256;
|
2016-11-07 12:07:29 +01:00
|
|
|
};
|
|
|
|
|
2019-05-22 18:34:09 +02:00
|
|
|
nativeBuildInputs = [ addOpenGLRunpath ];
|
|
|
|
|
2016-11-07 12:07:29 +01:00
|
|
|
installPhase = ''
|
2021-03-09 14:04:39 +09:00
|
|
|
runHook preInstall
|
|
|
|
|
2016-11-07 12:07:29 +01:00
|
|
|
function fixRunPath {
|
|
|
|
p=$(patchelf --print-rpath $1)
|
2021-02-14 11:27:50 +01:00
|
|
|
patchelf --set-rpath "''${p:+$p:}${lib.makeLibraryPath [ stdenv.cc.cc ]}:\$ORIGIN/" $1
|
2016-11-07 12:07:29 +01:00
|
|
|
}
|
2021-02-14 11:27:50 +01:00
|
|
|
|
|
|
|
for lib in lib64/lib*.so; do
|
|
|
|
fixRunPath $lib
|
|
|
|
done
|
2016-11-07 12:07:29 +01:00
|
|
|
|
|
|
|
mkdir -p $out
|
|
|
|
cp -a include $out/include
|
|
|
|
cp -a lib64 $out/lib64
|
2021-03-09 14:04:39 +09:00
|
|
|
'' + lib.optionalString removeStatic ''
|
|
|
|
rm -f $out/lib64/*.a
|
|
|
|
'' + ''
|
|
|
|
runHook postInstall
|
2016-11-07 12:07:29 +01:00
|
|
|
'';
|
|
|
|
|
2019-05-22 18:34:09 +02:00
|
|
|
# Set RUNPATH so that libcuda in /run/opengl-driver(-32)/lib can be found.
|
|
|
|
# See the explanation in addOpenGLRunpath.
|
|
|
|
postFixup = ''
|
2020-08-28 15:12:50 -05:00
|
|
|
for lib in $out/lib/lib*.so; do
|
2021-02-14 11:15:02 +01:00
|
|
|
addOpenGLRunpath $lib
|
2020-08-28 15:12:50 -05:00
|
|
|
done
|
2019-05-22 18:34:09 +02:00
|
|
|
'';
|
|
|
|
|
2016-11-07 12:07:29 +01:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
cudatoolkit
|
|
|
|
];
|
|
|
|
|
2017-10-15 14:44:54 +03:00
|
|
|
passthru = {
|
|
|
|
inherit cudatoolkit;
|
2019-09-24 11:24:13 +02:00
|
|
|
majorVersion = lib.versions.major version;
|
2017-10-15 14:44:54 +03:00
|
|
|
};
|
|
|
|
|
2021-01-22 00:00:13 +07:00
|
|
|
meta = with lib; {
|
2016-11-07 12:07:29 +01:00
|
|
|
description = "NVIDIA CUDA Deep Neural Network library (cuDNN)";
|
2017-09-17 07:07:40 +03:00
|
|
|
homepage = "https://developer.nvidia.com/cudnn";
|
|
|
|
license = licenses.unfree;
|
|
|
|
platforms = [ "x86_64-linux" ];
|
2016-11-07 12:07:29 +01:00
|
|
|
maintainers = with maintainers; [ mdaiter ];
|
|
|
|
};
|
|
|
|
}
|