From 84786ebecd08ca6bf61ebda039ffc608a7f88083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20de=20Kok?= Date: Sun, 14 Feb 2021 11:15:02 +0100 Subject: [PATCH 1/2] cudnn_cudatoolkit_11: remove libcudnn_cnn_infer.so exception With the update to CuDNN 8.1, we do not get the "maximum file size exceeded" error anymore when patchelf'ing libcudnn_cnn_infer.so. This change removes the exception for that library. --- pkgs/development/libraries/science/math/cudnn/generic.nix | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/pkgs/development/libraries/science/math/cudnn/generic.nix b/pkgs/development/libraries/science/math/cudnn/generic.nix index 59c0b7f4498..e5f09f142dd 100644 --- a/pkgs/development/libraries/science/math/cudnn/generic.nix +++ b/pkgs/development/libraries/science/math/cudnn/generic.nix @@ -38,13 +38,7 @@ stdenv.mkDerivation { # See the explanation in addOpenGLRunpath. postFixup = '' for lib in $out/lib/lib*.so; do - # patchelf fails on libcudnn_cnn_infer due to it being too big. - # Most programs will still get the RPATH since they link to - # other things. - # (https://github.com/NixOS/patchelf/issues/222) - if [ "$(basename $lib)" != libcudnn_cnn_infer.so ]; then - addOpenGLRunpath $lib - fi + addOpenGLRunpath $lib done ''; From 8dad19aebeef4c8775df46e3485c73cfd126c2c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20de=20Kok?= Date: Sun, 14 Feb 2021 11:27:50 +0100 Subject: [PATCH 2/2] cudnn_cudatookit_11: add $ORIGIN/ to library RPATHs Starting with version 8, CuDNN consists of multiple libraries. Libraries (except libcudnn.so) are dlopen()ed on demand. Since the CuDNN library path itself was not added to the rpath of the libraries, use of CuDNN often fails with the following error: Could not load library libcudnn_cnn_train.so.8. Error: libcudnn_ops_train.so.8: cannot open shared object file: No such file or directory Please make sure libcudnn_cnn_train.so.8 is in your library path! This change fixes this by adding $ORIGIN/ to the rpath of all CuDNN libraries. --- pkgs/development/libraries/science/math/cudnn/generic.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/science/math/cudnn/generic.nix b/pkgs/development/libraries/science/math/cudnn/generic.nix index e5f09f142dd..566a17c6147 100644 --- a/pkgs/development/libraries/science/math/cudnn/generic.nix +++ b/pkgs/development/libraries/science/math/cudnn/generic.nix @@ -25,9 +25,12 @@ stdenv.mkDerivation { installPhase = '' function fixRunPath { p=$(patchelf --print-rpath $1) - patchelf --set-rpath "$p:${lib.makeLibraryPath [ stdenv.cc.cc ]}" $1 + patchelf --set-rpath "''${p:+$p:}${lib.makeLibraryPath [ stdenv.cc.cc ]}:\$ORIGIN/" $1 } - fixRunPath lib64/libcudnn.so + + for lib in lib64/lib*.so; do + fixRunPath $lib + done mkdir -p $out cp -a include $out/include