1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-02-19 17:39:34 +00:00

Add driver library path to some packages to find CUDA libraries.

This is to avoid relying on LD_LIBRARY_PATH for finding the CUDA driver libraries.
This commit is contained in:
Ambroz Bizjak 2019-05-22 18:34:09 +02:00
parent 1860e506e7
commit 28a0918916
4 changed files with 39 additions and 6 deletions
pkgs
applications/misc/blender
development
compilers/cudatoolkit
libraries/science/math

View file

@ -2,7 +2,7 @@
, ilmbase, libXi, libX11, libXext, libXrender , ilmbase, libXi, libX11, libXext, libXrender
, libjpeg, libpng, libsamplerate, libsndfile , libjpeg, libpng, libsamplerate, libsndfile
, libtiff, libGLU_combined, openal, opencolorio, openexr, openimageio, openjpeg_1, pythonPackages , libtiff, libGLU_combined, openal, opencolorio, openexr, openimageio, openjpeg_1, pythonPackages
, zlib, fftw, opensubdiv, freetype, jemalloc, ocl-icd , zlib, fftw, opensubdiv, freetype, jemalloc, ocl-icd, addOpenGLRunpath
, jackaudioSupport ? false, libjack2 , jackaudioSupport ? false, libjack2
, cudaSupport ? config.cudaSupport or false, cudatoolkit , cudaSupport ? config.cudaSupport or false, cudatoolkit
, colladaSupport ? true, opencollada , colladaSupport ? true, opencollada
@ -21,8 +21,9 @@ stdenv.mkDerivation rec {
sha256 = "1g4kcdqmf67srzhi3hkdnr4z1ph4h9sza1pahz38mrj998q4r52c"; sha256 = "1g4kcdqmf67srzhi3hkdnr4z1ph4h9sza1pahz38mrj998q4r52c";
}; };
nativeBuildInputs = [ cmake ] ++ optional cudaSupport addOpenGLRunpath;
buildInputs = buildInputs =
[ boost cmake ffmpeg gettext glew ilmbase [ boost ffmpeg gettext glew ilmbase
libXi libX11 libXext libXrender libXi libX11 libXext libXrender
freetype libjpeg libpng libsamplerate libsndfile libtiff libGLU_combined openal freetype libjpeg libpng libsamplerate libsndfile libtiff libGLU_combined openal
opencolorio openexr openimageio openjpeg_1 python zlib fftw jemalloc opencolorio openexr openimageio openjpeg_1 python zlib fftw jemalloc
@ -80,6 +81,15 @@ stdenv.mkDerivation rec {
--prefix PYTHONPATH : ${pythonPackages.numpy}/${python.sitePackages} --prefix PYTHONPATH : ${pythonPackages.numpy}/${python.sitePackages}
''; '';
# Set RUNPATH so that libcuda and libnvrtc in /run/opengl-driver(-32)/lib can be
# found. See the explanation in libglvnd.
postFixup = optionalString cudaSupport ''
for program in $out/bin/blender $out/bin/.blender-wrapped; do
isELF "$program" || continue
addOpenGLRunpath "$program"
done
'';
meta = with stdenv.lib; { meta = with stdenv.lib; {
description = "3D Creation/Animation/Publishing System"; description = "3D Creation/Animation/Publishing System";
homepage = https://www.blender.org; homepage = https://www.blender.org;

View file

@ -1,6 +1,7 @@
{ lib, stdenv, makeWrapper, fetchurl, requireFile, perl, ncurses5, expat, python27, zlib { lib, stdenv, makeWrapper, fetchurl, requireFile, perl, ncurses5, expat, python27, zlib
, gcc48, gcc49, gcc5, gcc6, gcc7 , gcc48, gcc49, gcc5, gcc6, gcc7
, xorg, gtk2, gdk_pixbuf, glib, fontconfig, freetype, unixODBC, alsaLib, glibc , xorg, gtk2, gdk_pixbuf, glib, fontconfig, freetype, unixODBC, alsaLib, glibc
, addOpenGLRunpath
}: }:
let let
@ -39,7 +40,7 @@ let
outputs = [ "out" "lib" "doc" ]; outputs = [ "out" "lib" "doc" ];
nativeBuildInputs = [ perl makeWrapper ]; nativeBuildInputs = [ perl makeWrapper addOpenGLRunpath ];
buildInputs = [ gdk_pixbuf ]; # To get $GDK_PIXBUF_MODULE_FILE via setup-hook buildInputs = [ gdk_pixbuf ]; # To get $GDK_PIXBUF_MODULE_FILE via setup-hook
runtimeDependencies = [ runtimeDependencies = [
ncurses5 expat python zlib glibc ncurses5 expat python zlib glibc
@ -143,10 +144,19 @@ let
else else
rpath2=$rpath:$lib/lib:$out/jre/lib/amd64/jli:$out/lib:$out/lib64:$out/nvvm/lib:$out/nvvm/lib64 rpath2=$rpath:$lib/lib:$out/jre/lib/amd64/jli:$out/lib:$out/lib64:$out/nvvm/lib:$out/nvvm/lib64
fi fi
patchelf --set-rpath $rpath2 --force-rpath $i patchelf --set-rpath "$rpath2" --force-rpath $i
done < <(find $out $lib $doc -type f -print0) done < <(find $out $lib $doc -type f -print0)
''; '';
# Set RPATH so that libcuda and other libraries in
# /run/opengl-driver(-32)/lib can be found. See the explanation in
# addOpenGLRunpath. Don't try to figure out which libraries really need
# it, just patch all (but not the stubs libraries). Note that
# --force-rpath prevents changing RPATH (set above) to RUNPATH.
postFixup = ''
addOpenGLRunpath --force-rpath {$out,$lib}/lib/lib*.so
'';
# cuda-gdb doesn't run correctly when not using sandboxing, so # cuda-gdb doesn't run correctly when not using sandboxing, so
# temporarily disabling the install check. This should be set to true # temporarily disabling the install check. This should be set to true
# when we figure out how to get `cuda-gdb --version` to run correctly # when we figure out how to get `cuda-gdb --version` to run correctly

View file

@ -7,6 +7,7 @@
, lib , lib
, cudatoolkit , cudatoolkit
, fetchurl , fetchurl
, addOpenGLRunpath
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
@ -19,6 +20,8 @@ stdenv.mkDerivation rec {
inherit sha256; inherit sha256;
}; };
nativeBuildInputs = [ addOpenGLRunpath ];
installPhase = '' installPhase = ''
function fixRunPath { function fixRunPath {
p=$(patchelf --print-rpath $1) p=$(patchelf --print-rpath $1)
@ -31,6 +34,12 @@ stdenv.mkDerivation rec {
cp -a lib64 $out/lib64 cp -a lib64 $out/lib64
''; '';
# Set RUNPATH so that libcuda in /run/opengl-driver(-32)/lib can be found.
# See the explanation in addOpenGLRunpath.
postFixup = ''
addOpenGLRunpath $out/lib/lib*.so
'';
propagatedBuildInputs = [ propagatedBuildInputs = [
cudatoolkit cudatoolkit
]; ];

View file

@ -1,4 +1,4 @@
{ stdenv, fetchFromGitHub, which, cudatoolkit }: { stdenv, fetchFromGitHub, which, cudatoolkit, addOpenGLRunpath }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "nccl-${version}-cuda-${cudatoolkit.majorVersion}"; name = "nccl-${version}-cuda-${cudatoolkit.majorVersion}";
@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
outputs = [ "out" "dev" ]; outputs = [ "out" "dev" ];
nativeBuildInputs = [ which ]; nativeBuildInputs = [ which addOpenGLRunpath ];
buildInputs = [ cudatoolkit ]; buildInputs = [ cudatoolkit ];
@ -28,6 +28,10 @@ stdenv.mkDerivation rec {
postFixup = '' postFixup = ''
moveToOutput lib/libnccl_static.a $dev moveToOutput lib/libnccl_static.a $dev
# Set RUNPATH so that libnvidia-ml in /run/opengl-driver(-32)/lib can be found.
# See the explanation in addOpenGLRunpath.
addOpenGLRunpath $out/lib/lib*.so
''; '';
NIX_CFLAGS_COMPILE = [ "-Wno-unused-function" ]; NIX_CFLAGS_COMPILE = [ "-Wno-unused-function" ];