From c1f04f375c0e8ecf8d8fa81e99b0d41f2c1788b3 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Wed, 24 Jun 2026 18:52:18 +0000 Subject: [PATCH] python3Packages.torch: fix inductor on darwin --- pkgs/development/python-modules/torch/source/default.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/development/python-modules/torch/source/default.nix b/pkgs/development/python-modules/torch/source/default.nix index f807e1a696e4..1f1a5948f586 100644 --- a/pkgs/development/python-modules/torch/source/default.nix +++ b/pkgs/development/python-modules/torch/source/default.nix @@ -385,6 +385,15 @@ buildPythonPackage.override { inherit stdenv; } (finalAttrs: { # until https://github.com/pytorch/pytorch/issues/76082 is addressed + lib.optionalString cudaSupport '' rm cmake/Modules/FindCUDAToolkit.cmake + '' + # Otherwise, torch compile will fail at runtime if openmp is not available + # torch._inductor.exc.InductorError: CppCompileError: C++ compile error + # fatal error: 'omp.h' file not found + + lib.optionalString stdenv.hostPlatform.isDarwin '' + substituteInPlace torch/csrc/inductor/cpp_prefix.h \ + --replace-fail \ + "#include " \ + '#include "${lib.getInclude llvmPackages.openmp}/include/omp.h"' ''; # NOTE(@connorbaker): Though we do not disable Gloo or MPI when building with CUDA support, caution should be taken