Skip to content

Commit

Permalink
Merge pull request NixOS#220017 from azuwis/torch
Browse files Browse the repository at this point in the history
python3Packages.torch: Fix performance problem on darwin
  • Loading branch information
wegank authored Mar 14, 2023
2 parents 39286f0 + 0d758c2 commit 1474943
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions pkgs/development/python-modules/torch/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ stdenv, lib, fetchFromGitHub, fetchpatch, buildPythonPackage, python,
cudaSupport ? false, cudaPackages, magma,
mklDnnSupport ? true, useSystemNccl ? true,
useSystemNccl ? true,
MPISupport ? false, mpi,
buildDocs ? false,

Expand All @@ -9,14 +9,18 @@

# Build inputs
numactl,
CoreServices, libobjc,
Accelerate, CoreServices, libobjc,

# Propagated build inputs
numpy, pyyaml, cffi, click, typing-extensions,

# Unit tests
hypothesis, psutil,

# Disable MKLDNN on aarch64-darwin, it negatively impacts performance,
# this is also what official pytorch build does
mklDnnSupport ? !(stdenv.isDarwin && stdenv.isAarch64),

# virtual pkg that consistently instantiates blas across nixpkgs
# See https://github.com/NixOS/nixpkgs/pull/83888
blas,
Expand Down Expand Up @@ -275,7 +279,7 @@ in buildPythonPackage rec {
++ lib.optionals rocmSupport [ openmp ]
++ lib.optionals (cudaSupport || rocmSupport) [ magma ]
++ lib.optionals stdenv.isLinux [ numactl ]
++ lib.optionals stdenv.isDarwin [ CoreServices libobjc ];
++ lib.optionals stdenv.isDarwin [ Accelerate CoreServices libobjc ];

propagatedBuildInputs = [
cffi
Expand Down
2 changes: 1 addition & 1 deletion pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11715,7 +11715,7 @@ self: super: with self; {

torch = callPackage ../development/python-modules/torch {
cudaSupport = pkgs.config.cudaSupport or false;
inherit (pkgs.darwin.apple_sdk.frameworks) CoreServices;
inherit (pkgs.darwin.apple_sdk.frameworks) Accelerate CoreServices;
inherit (pkgs.darwin) libobjc;
inherit (pkgs.llvmPackages_rocm) openmp;
};
Expand Down

0 comments on commit 1474943

Please sign in to comment.