Friday, January 12, 2018

How to install pytorch on mac osx high sierra 10.13.02 with egpu Akitio 3

Check my previous post on how to get Akitio 3 working on Mac OSX high sierra

http://olivernina.blogspot.com/2018/01/how-to-install-akitio-3-m6000-to-mac.html

This post is mainly on compiling and installing pytorch from source for Mac.
Installing pytorch in MacOS X with an external gpu could be cumbersome. I compiled pytorch from source before and there are a few main details to pay attention in order to succeed. I found this video that was helpful on getting this working.

https://www.youtube.com/watch?v=h8n6HrLfeJQ


The main instructions are as follows
Assuming you have your GPU working properly.

Install xcode. I got the version that comes with 10.13.02

Install homebrew as instructed in https://brew.sh/

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Update homebrew:

brew update

install anaconda. You can do it through brew or downloading the installer from their website.

Install cuda. Verify which version works with your driver. My driver is 378.10.10.10.25.102
You will also need to install the CUDA toolkit that will have the compiler and other tools for compiling CUDA code. My verison for the toolkit is 9.1.

Install cudnn. Also verify which version works with the CUDA version you have


clone pytorch from source

git clone --recursive https://github.com/pytorch/pytorch

According to pytorch you have to update some tools
conda install numpy pyyaml setuptools cmake cffi

Define path for cmake which is where your anaconda is,  in my case was:
export CMAKE_PREFIX_PATH=/Users/oliver/anaconda/

Make sure clang --version works with the CUDA you have. My setup works only with clang version 8.1.0 (clang-802.0.42)
Thus I need to go to https://developer.apple.com/download/more/
and download Command Line Tools for Xcode 8.3.2
Install the command line tools and then run
sudo xcode-select --switch /Library/Developer/CommandLineTools

Then compile and  install pytorch.

MACOSX_DEPLOYMENT_TARGET=10.13 CC=clang CXX=clang++ python setup.py install

That is it. Good luck!

No comments: