Tensorflow GPU 1.8 with MacOS 10.13.6
A guide to install and make work an already compiled version of Tensorflow 1.8 - GPU on MacOS 10.13.6.
PREREQUISITE: Having an Nvidia GPU or EGPU (already working)
These are the required steps:
(note: follow the guide at your own risk.
note2: Big part of this guide is taken from this other guide):
1. Install Homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" brew install wget
2. Install Nvidia Web Drivers:
3. Install Nvidia Cuda Drivers:
4. Download Xcode 8.2.xip and Xcode 9.4.xip, extract both .app files, rename them to Xcode8.2.app and Xcode9.4 respectively and move then to Applications folder:
You need to search for them there, they're about 4.2GB and 5.2GB. V9.4 will be needed to install OpenMP, which suggests to install that version. I don't know if latest Xcode version works instead of 9.4, if you already have latest, you could try to use that. V8.2 is essential, anyway.
5. Set Xcode8.2 as default:
sudo xcode-select -s /Applications/Xcode8.2.app
6. Install bazel:
brew install bazel
7. Install cuda 9.1.128:
8. Download and install nccl 1.3.4:
unarchive it, open a terminal window into the extracted folder and move it into /usr/local/nccl by performing:
sudo mkdir -p /usr/local/nccl cd nccl_2.1.15-1+cuda9.1_x86_64 sudo mv * /usr/local/nccl sudo mkdir -p /usr/local/include/third_party/nccl sudo ln -s /usr/local/nccl/include/nccl.h /usr/local/include/third_party/nccl
9. Edit ~/.bash_profile by inserting:
export CUDA_HOME=/usr/local/cuda export DYLD_LIBRARY_PATH=/usr/local/cuda/lib:/usr/local/cuda/extras/CUPTI/lib export LD_LIBRARY_PATH=$DYLD_LIBRARY_PATH export PATH=$DYLD_LIBRARY_PATH:$PATH:/Developer/NVIDIA/CUDA-9.1/bin
10. Compile CUDA samples to test if GPU is working correctly:
cd /Developer/NVIDIA/CUDA-9.1/samples chown -R $(whoami) * make -C 1_Utilities/deviceQuery ./bin/x86_64/darwin/release/deviceQuery
You should get this result at the bottom of the terminal:
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 9.1, CUDA Runtime Version = 9.1, NumDevs = 1Result = PASS
11. Register here and download cuDNN 7.0.5:
tar -xzvf cudnn-9.1-osx-x64-v7-ga.tgz sudo cp cuda/include/cudnn.h /usr/local/cuda/include sudo cp cuda/lib/libcudnn* /usr/local/cuda/lib sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib/libcudnn*
to extract and copy required files into CUDA install folder.
12. Download and install Python 3.6.4:
Now this is where i stopped following the guide.
13. Install Tensorflow 1.8 (other versions HERE):
pip3 install https://storage.googleapis.com/74thopen/tensorflow_osx/tensorflow-1.8.0-cp36-cp36m-macosx_10_13_x86_64.whl
14. Set Xcode9.4 as default:
sudo xcode-select -s /Applications/Xcode9.4.app
15. Install OpenMP:
brew install cliutils/apple/libomp
16. Finally, test the whole installation: Run in terminal:
>>> import tensorflow as tf >>> tf.Session()
you should get some messages about your GPU, memory and others (### i will insert the exact returned message ###).
17. If you get -ncclAllReduce issue:
- Download file here:
gcc -c -fPIC nccl_ops.cc -o hello_world.o
gcc hello_world.o -shared -o _nccl_ops.so
- Replace generated file "nccl_ops.so" at Path:
To find where TF is installed:
pip3 show tensorflow
you will get:
Summary: TensorFlow helps the tensors flow
Author: Google Inc.
License: Apache 2.0
Requires: grpcio, tensorboard, wheel, astor, gast, protobuf, termcolor, numpy, six, absl-py
Then repeat step 16, if everything works, congratulations, you have tensorflow 1.8 with GPU support installed!
Moreover, if you want to test a sample code to be sure everything really works, then download and run