python3Packages.pytorch: unbreak on Darwin (#177812)

* Add missing `buildInputs`.
* Enable Grand Central Dispatch support for `aarch64-darwin`.
* Remove `postFixup` steps for .dylib files that aren't present.
main
Malo Bourgon 2 years ago committed by GitHub
parent 1f95c49331
commit 206a9575b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      pkgs/development/python-modules/pytorch/default.nix
  2. 2
      pkgs/top-level/python-packages.nix

@ -10,6 +10,7 @@
# Build inputs
numactl,
CoreServices, libobjc,
# Propagated build inputs
numpy, pyyaml, cffi, click, typing-extensions,
@ -145,7 +146,7 @@ in buildPythonPackage rec {
# https://github.com/pytorch/pytorch/issues/70297
# https://github.com/google/breakpad/commit/605c51ed96ad44b34c457bbca320e74e194c317e
./breakpad-sigstksz.patch
] ++ lib.optionals stdenv.isDarwin [
] ++ lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [
# pthreadpool added support for Grand Central Dispatch in April
# 2020. However, this relies on functionality (DISPATCH_APPLY_AUTO)
# that is available starting with macOS 10.13. However, our current
@ -229,7 +230,8 @@ in buildPythonPackage rec {
buildInputs = [ blas blas.provider pybind11 ]
++ lib.optionals cudaSupport [ cudnn magma nccl ]
++ lib.optionals stdenv.isLinux [ numactl ];
++ lib.optionals stdenv.isLinux [ numactl ]
++ lib.optionals stdenv.isDarwin [ CoreServices libobjc ];
propagatedBuildInputs = [
cffi
@ -295,15 +297,6 @@ in buildPythonPackage rec {
install_name_tool -change @rpath/libc10.dylib $lib/lib/libc10.dylib $lib/lib/libtorch.dylib
install_name_tool -change @rpath/libtorch.dylib $lib/lib/libtorch.dylib $lib/lib/libcaffe2_observers.dylib
install_name_tool -change @rpath/libc10.dylib $lib/lib/libc10.dylib $lib/lib/libcaffe2_observers.dylib
install_name_tool -change @rpath/libtorch.dylib $lib/lib/libtorch.dylib $lib/lib/libcaffe2_module_test_dynamic.dylib
install_name_tool -change @rpath/libc10.dylib $lib/lib/libc10.dylib $lib/lib/libcaffe2_module_test_dynamic.dylib
install_name_tool -change @rpath/libtorch.dylib $lib/lib/libtorch.dylib $lib/lib/libcaffe2_detectron_ops.dylib
install_name_tool -change @rpath/libc10.dylib $lib/lib/libc10.dylib $lib/lib/libcaffe2_detectron_ops.dylib
install_name_tool -change @rpath/libtorch.dylib $lib/lib/libtorch.dylib $lib/lib/libshm.dylib
install_name_tool -change @rpath/libc10.dylib $lib/lib/libc10.dylib $lib/lib/libshm.dylib
'';
@ -319,12 +312,11 @@ in buildPythonPackage rec {
};
meta = with lib; {
# darwin: error: use of undeclared identifier 'noU'; did you mean 'no'?
broken = (stdenv.isLinux && stdenv.isAarch64) || stdenv.isDarwin;
description = "Open source, prototype-to-production deep learning platform";
homepage = "https://pytorch.org/";
license = licenses.bsd3;
platforms = with platforms; linux ++ lib.optionals (!cudaSupport) darwin;
maintainers = with maintainers; [ teh thoughtpolice tscholak ]; # tscholak esp. for darwin-related builds
platforms = with platforms; linux ++ lib.optionals (!cudaSupport) darwin;
broken = stdenv.isLinux && stdenv.isAarch64;
};
}

@ -8762,6 +8762,8 @@ in {
pytorch = callPackage ../development/python-modules/pytorch {
cudaSupport = pkgs.config.cudaSupport or false;
inherit (pkgs.darwin.apple_sdk.frameworks) CoreServices;
inherit (pkgs.darwin) libobjc;
};
pytorch-bin = callPackage ../development/python-modules/pytorch/bin.nix { };

Loading…
Cancel
Save