python3Packages.torch-bin: only include Linux-specific dependencies when building on Linux

This fixes a build regression on aarch64-darwin that has prevented torch-bin from being buildable since the merge of #227420.
This commit is contained in:
Charles Duffy
2023-06-07 18:05:54 -05:00
parent 54ea6f60f0
commit 2312d0f9f0
@@ -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