Install Pytorch with GPU support on High Sierra

2017-12-15T16:30:00

Upgrade CUDA driver

export DYLD_LIBRARY_PATH=/usr/local/cuda/lib:$DYLD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
conda install numpy pyyaml setuptools cmake cffi # provided by pytorch README
# I remember some packages need newest version of mkl which is 2018-01, but default mkl in anaconda is mkl2017
conda upgrade mkl 
export CMAKE_PREFIX_PATH=[anaconda root directory] # temporal env variable
# get source code
# following command will get newest pytorch v0.4.0
git clone --recursive https://github.com/pytorch/pytorch
cd pytorch
# make and install
# it is fine using target 10.9; 
MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install
# Optional !!!!!! if it failed before; do clean first
MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py clean