diff --git a/pkgs/development/python-modules/torch/bin.nix b/pkgs/development/python-modules/torch/bin.nix index b830b41527fd..ec8ec52b2430 100644 --- a/pkgs/development/python-modules/torch/bin.nix +++ b/pkgs/development/python-modules/torch/bin.nix @@ -40,18 +40,19 @@ in buildPythonPackage { nativeBuildInputs = [ addOpenGLRunpath + patchelf + ] ++ lib.optionals stdenv.isLinux [ autoPatchelfHook cudaPackages.autoAddOpenGLRunpathHook - patchelf ]; - buildInputs = with cudaPackages; [ + buildInputs = lib.optionals stdenv.isLinux (with cudaPackages; [ # $out/${sitePackages}/nvfuser/_C*.so wants libnvToolsExt.so.1 but torch/lib only ships # libnvToolsExt-$hash.so.1 cuda_nvtx - ]; + ]); - autoPatchelfIgnoreMissingDeps = [ + autoPatchelfIgnoreMissingDeps = lib.optionals stdenv.isLinux [ # This is the hardware-dependent userspace driver that comes from # nvidia_x11 package. It must be deployed at runtime in # /run/opengl-driver/lib or pointed at by LD_LIBRARY_PATH variable, rather @@ -79,7 +80,7 @@ in buildPythonPackage { rm -rf $out/bin ''; - postFixup = '' + postFixup = lib.optionalString stdenv.isLinux '' addAutoPatchelfSearchPath "$out/${python.sitePackages}/torch/lib" patchelf $out/${python.sitePackages}/torch/lib/libcudnn.so.8 --add-needed libcudnn_cnn_infer.so.8