Forked from rfeinman/build_pytorch_openmp_mkl_macOS.sh
Created
January 12, 2022 07:53
-
-
Save Yevgnen/6207cdcfcf723f2639b383de8e0c72ad to your computer and use it in GitHub Desktop.
Build PyTorch with MKL & OpenMP threading on macOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# This install used the following development environment: | |
# - We have installed xcode command line tools | |
# - We have installed cmake via homebrew (my version is 3.20.2) | |
# - We have created a fresh conda environment "pytorch-dev" and installed | |
# python=3.8 and all of the packages from pytorch/README.md except cmake | |
# (including the torch.distributed deps) | |
# - We have copied the relevant OpenMP header files into a fresh directory at ~/openmp | |
# - We have cloned the pytorch github repo to ~/pytorch | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# conda environment where we have installed dependencies | |
conda activate pytorch-dev | |
# root directory of our conda environment | |
CONDA_ENV=${CONDA_PREFIX:-"$(dirname $(which conda))/../"} | |
# directory where we have placed the intel openmp header files | |
OMP_INCLUDE=$HOME/openmp/include | |
# these two exports are necessary | |
export CMAKE_PREFIX_PATH=$CONDA_ENV | |
export CMAKE_INCLUDE_PATH=$OMP_INCLUDE | |
# not 100% sure these two exports are necessary, but worked for me | |
export CMAKE_SHARED_LINKER_FLAGS="$CONDA_ENV/lib/libiomp5.dylib -Wl,-rpath,$CONDA_ENV/lib" | |
export CMAKE_EXE_LINKER_FLAGS="$CONDA_ENV/lib/libiomp5.dylib -Wl,-rpath,$CONDA_ENV/lib" | |
export MACOSX_DEPLOYMENT_TARGET=11.0 | |
export CC=clang | |
export CXX=clang++ | |
export MAX_JOBS=9 | |
export BLAS=MKL | |
export USE_OPENMP=1 | |
export MKL_THREADING=OMP | |
export ATEN_THREADING=OMP | |
export MKLDNN_CPU_RUNTIME=OMP | |
# directory where we have cloned pytorch | |
cd $HOME/pytorch | |
python setup.py install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment