python3Packages.torch: fix inductor on darwin

This commit is contained in:
Gaetan Lepage
2026-07-03 21:38:52 +00:00
parent fd62b27025
commit c1f04f375c
@@ -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 <omp.h>" \
'#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