Skip to content

Commit

Permalink
Refix openmp on mac
Browse files Browse the repository at this point in the history
  • Loading branch information
HGuillemet committed Jun 25, 2024
1 parent 5b9e86c commit 01199eb
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 17 deletions.
23 changes: 15 additions & 8 deletions .github/actions/deploy-macosx/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ 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 libuv
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 libomp
# Install version of libomp for llvm 15
# brew uninstall -f libomp
#curl -LO https://mac.r-project.org/openmp/openmp-15.0.7-darwin20-Release.tar.gz
#tar fvxz openmp-15.0.7-darwin20-Release.tar.gz -C /
# echo Installing an older less buggy version of CMake
# curl -LO https://raw.githubusercontent.com/Homebrew/homebrew-core/30a3e5e02420a515f9bad02e3cfcde95316db529/Formula/cmake.rb
# brew unlink cmake
Expand All @@ -53,17 +57,19 @@ runs:
sudo install_name_tool -change /usr/local/lib/gcc/10/libgcc_s.1.dylib @rpath/libgcc_s.1.dylib /usr/local/lib/gcc/10/libgfortran.5.dylib
sudo install_name_tool -change /usr/local/lib/gcc/10/libgcc_s.1.dylib @rpath/libgcc_s.1.dylib /usr/local/lib/gcc/10/libquadmath.0.dylib
otool -L /usr/local/lib/gcc/10/*.dylib
else
brew link libomp --force
fi
sudo install_name_tool -add_rpath @loader_path/. -id @rpath/libomp.dylib /usr/local/opt/libomp/lib/libomp.dylib
sudo install_name_tool -add_rpath @loader_path/. -id @rpath/libSDL2-2.0.0.dylib /usr/local/opt/sdl2/lib/libSDL2-2.0.0.dylib
sudo install_name_tool -add_rpath @loader_path/. -id @rpath/libusb-1.0.0.dylib /usr/local/opt/libusb/lib/libusb-1.0.0.dylib
#sudo install_name_tool -add_rpath @loader_path/. -id @rpath/libomp.dylib /usr/local/opt/libomp/lib/libomp.dylib
sudo install_name_tool -add_rpath @loader_path/. -id @rpath/libSDL2-2.0.0.dylib `brew ls sdl2|grep libSDL2-2.0.0.dylib`
sudo install_name_tool -add_rpath @loader_path/. -id @rpath/libusb-1.0.0.dylib `brew ls libusb|grep libusb-1.0.0.dylib`
curl -LO https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
sudo tar -xzf apache-maven-3.6.3-bin.tar.gz -C /usr/local/opt
sudo ln -sf /usr/local/opt/apache-maven-3.6.3/bin/mvn /usr/local/bin/mvn
python3 -m pip install gdown || python3 -m pip install gdown
PIP_BREAK_SYSTEM_PACKAGES=1 python3 -m pip install gdown || python3 -m pip install gdown
# Install vulkan sdk
echo Installing Vulkan SDK
Expand Down Expand Up @@ -111,6 +117,7 @@ runs:
git --version
clang --version
/usr/local/bin/gcc-* --version || true
which cmake
cmake --version
gradle --version
mvn -version
Expand Down
9 changes: 1 addition & 8 deletions .github/workflows/pytorch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ jobs:
runs-on: macos-12
steps:
- uses: HGuillemet/javacpp-presets/.github/actions/deploy-macosx@apteryx_pytorch
macosx-x86_64:
runs-on: macos-12
# strategy:
# matrix:
# ext: ["", -gpu]
steps:
- uses: HGuillemet/javacpp-presets/.github/actions/deploy-macosx@apteryx_pytorch
windows-x86_64:
runs-on: windows-2019
strategy:
Expand All @@ -65,7 +58,7 @@ jobs:
- uses: HGuillemet/javacpp-presets/.github/actions/deploy-windows@apteryx_pytorch
timeout-minutes: 350
redeploy:
needs: [linux-x86_64, macosx-arm64, macosx-x86_64, windows-x86_64]
needs: [linux-x86_64, macosx-arm64, windows-x86_64]
runs-on: ubuntu-20.04
steps:
- uses: HGuillemet/javacpp-presets/.github/actions/redeploy@apteryx_pytorch
28 changes: 27 additions & 1 deletion pytorch/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -211,9 +213,33 @@ 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
brew ls libomp
#export CMAKE_INCLUDE_PATH=/usr/local/Cellar/libomp/18.1.7/include
#export CMAKE_LIBRARY_PATH=/usr/local/Cellar/libomp/18.1.7/lib
#if [[ ! -e $CMAKE_INCLUDE_PATH ]]; then
# echo libomp 18.1.7 not found
# exit 1
#fi
export CMAKE_INCLUDE_PATH=/usr/local/include
export CMAKE_LIBRARY_PATH=/usr/local/lib
#echo Setting CMAKE_INCLUDE_PATH=$CMAKE_INCLUDE_PATH
#echo Setting CMAKE_LIBRARY_PATH=$CMAKE_LIBRARY_PATH
export LD_LIBRARY_PATH=$CMAKE_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$CMAKE_LIBRARY_PATH
export OpenMP_C_INCLUDE_DIR=$CMAKE_INCLUDE_PATH
export OpenMP_CXX_INCLUDE_DIR=$CMAKE_INCLUDE_PATH
#export CXXFLAGS="-I$CMAKE_INCLUDE_PATH ${CXXFLAGS:-}"
#export CFLAGS="-I$CMAKE_INCLUDE_PATH ${CFLAGS:-}"
#export LDFLAGS="-L$CMAKE_LIBRARY_PATH ${LDFLAGS:-}"
#echo Setting CFLAGS=$CFLAGS
#echo Setting CXXFLAGS=$CXXFLAGS

#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 \
Expand Down

0 comments on commit 01199eb

Please sign in to comment.