From 61220d768de84ae996be5b0dda253f28e740fdab Mon Sep 17 00:00:00 2001 From: Mika Tammi Date: Sun, 27 Oct 2024 17:27:22 +0200 Subject: [PATCH] python3Packages.torch: switch to apple-sdk_13 Switch to apple-sdk_13 on Darwin. This enables the use of MPS (Metal Performance Shaders) on macOS. Signed-off-by: Mika Tammi --- pkgs/development/python-modules/torch/default.nix | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkgs/development/python-modules/torch/default.nix b/pkgs/development/python-modules/torch/default.nix index 25698776d83fa..578976fbb189e 100644 --- a/pkgs/development/python-modules/torch/default.nix +++ b/pkgs/development/python-modules/torch/default.nix @@ -35,7 +35,7 @@ removeReferencesTo, # Build inputs - darwin, + apple-sdk_13, numactl, # dependencies @@ -364,6 +364,9 @@ buildPythonPackage rec { # NB technical debt: building without NNPACK as workaround for missing `six` USE_NNPACK = 0; + # Explicitly enable MPS for Darwin + USE_MPS = setBool stdenv.hostPlatform.isDarwin; + cmakeFlags = [ # (lib.cmakeBool "CMAKE_FIND_DEBUG_MODE" true) @@ -519,9 +522,7 @@ buildPythonPackage rec { ++ lib.optionals (cudaSupport || rocmSupport) [ effectiveMagma ] ++ lib.optionals stdenv.hostPlatform.isLinux [ numactl ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ - darwin.apple_sdk.frameworks.Accelerate - darwin.apple_sdk.frameworks.CoreServices - darwin.libobjc + apple-sdk_13 ] ++ lib.optionals tritonSupport [ _tritonEffective ] ++ lib.optionals MPISupport [ mpi ]