From 65533e3611661c22cf6f8661fbcff704c512c601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Guillemet?= Date: Sun, 23 Jun 2024 11:06:08 +0200 Subject: [PATCH] Refix openmp on mac --- .github/actions/deploy-macosx/action.yml | 13 ++++++++++--- pytorch/cppbuild.sh | 14 +++++++++++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/.github/actions/deploy-macosx/action.yml b/.github/actions/deploy-macosx/action.yml index 3e8da39a906..0b66b4c135a 100644 --- a/.github/actions/deploy-macosx/action.yml +++ b/.github/actions/deploy-macosx/action.yml @@ -24,9 +24,15 @@ runs: sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/MacOSX10* fi - brew uninstall --force --ignore-dependencies gcc gcc@7 gcc@8 gcc@9 gcc@10 gcc@11 gcc@12 gcc@13 little-cms2 maven openblas r - brew install boost ccache swig autoconf-archive automake cmake libomp libtool libusb ant nasm xz pkg-config sdl2 gpg1 bison flex perl ragel binutils gradle gmp isl libmpc mpfr geoip pcre ssdeep yajl - brew link --force libomp + brew uninstall --force --ignore-dependencies gcc gcc@7 gcc@8 gcc@9 gcc@10 gcc@11 gcc@12 gcc@13 little-cms2 maven openblas r imagemagick libraw + brew install boost ccache swig autoconf-archive automake cmake libtool libusb ant nasm xz pkg-config sdl2 gpg1 bison flex perl ragel binutils gradle gmp isl libmpc mpfr geoip pcre ssdeep yajl + + # Install version of libomp for llvm 15 + brew uninstall -f libomp + curl -LO https://raw.githubusercontent.com/Homebrew/homebrew-core/2fae473b19b6cddd6f0e3aa1ad2932f44ff0316e/Formula/libomp.rb + ls -alR /usr/local/Cellar/libomp + brew install libomp.rb + brew link --force libomp -v # echo Installing an older less buggy version of CMake # curl -LO https://raw.githubusercontent.com/Homebrew/homebrew-core/30a3e5e02420a515f9bad02e3cfcde95316db529/Formula/cmake.rb @@ -111,6 +117,7 @@ runs: git --version clang --version /usr/local/bin/gcc-* --version || true + which cmake cmake --version gradle --version mvn -version diff --git a/pytorch/cppbuild.sh b/pytorch/cppbuild.sh index 9d2058219a6..def025534b1 100755 --- a/pytorch/cppbuild.sh +++ b/pytorch/cppbuild.sh @@ -143,6 +143,7 @@ case $PLATFORM in macosx-arm64) export CC="clang" export CXX="clang++" + export PATH=$(brew --prefix llvm@15)/bin:$PATH # Use brew LLVM 15 instead of Xcode LLVM 14 export CMAKE_OSX_ARCHITECTURES=arm64 # enable cross-compilation on a x86_64 host machine export USE_MKLDNN=OFF export USE_QNNPACK=OFF # not compatible with arm64 as of PyTorch 2.1.2 @@ -151,6 +152,7 @@ case $PLATFORM in macosx-x86_64) export CC="clang" export CXX="clang++" + export PATH=$(brew --prefix llvm@15)/bin:$PATH # Use brew LLVM 15 instead of Xcode LLVM 14 ;; windows-x86_64) if which ccache.exe; then @@ -211,9 +213,19 @@ sedinplace 's/const std::string& interface)/const std::string\& interface_name)/ # and see if choosing experimental works. See Issue #1503. # On Linux, pytorch FindOpenMP.cmake picks llvm libomp over libgomp. See Issue #1504. # Keep it on MacOS since it appends the correct -Xpreprocessor -fopenmp -I/usr/local/include flags -if [[ ! $PLATFORM == macosx-* ]]; then +#if [[ ! $PLATFORM == macosx-* ]]; then rm cmake/Modules/FindOpenMP.cmake sedinplace 's/include(${CMAKE_CURRENT_LIST_DIR}\/Modules\/FindOpenMP.cmake)/find_package(OpenMP)/g' cmake/Dependencies.cmake +if [[ $PLATFORM == macosx-* ]]; then + # export CXXFLAGS=-I/usr/local/include + export CMAKE_INCLUDE_PATH=/usr/local/include + export CMAKE_LIBRARY_PATH=/usr/local/lib + export LD_LIBRARY_PATH=/usr/local/lib + export DYLD_LIBRARY_PATH=/usr/local/lib + export OpenMP_C_INCLUDE_DIR=/usr/local/include + export OpenMP_CXX_INCLUDE_DIR=/usr/local/include + #curl -O https://mac.r-project.org/openmp/openmp-14.0.6-darwin20-Release.tar.gz + #tar fvxz openmp-14.0.6-darwin20-Release.tar.gz -C / fi #USE_FBGEMM=0 USE_KINETO=0 USE_GLOO=0 USE_MKLDNN=0 \