Skip to content

Instantly share code, notes, and snippets.

@nathanielatom
Last active July 8, 2016 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathanielatom/8c51c91d4bde3e37db0db705e8822e70 to your computer and use it in GitHub Desktop.
Save nathanielatom/8c51c91d4bde3e37db0db705e8822e70 to your computer and use it in GitHub Desktop.
Pseudo-script (meant to be read and executed line by line) for installing Tensorflow with GPU support on OS X.
# Tensorflow 0.9 with GPU from source for Mac OS X 10.11. Assumes anaconda python and homebrew is already installed.
# Requires ~8GB of storage, but only temporarily.
cd ~
conda update conda
conda update anaconda
conda install --channel https://conda.anaconda.org/conda-forge protobuf=3.0.0b2.post2
brew update
brew install Caskroom/cask/java
brew install bazel swig coreutils
brew tap caskroom/cask
brew cask install cuda
rm -rf $(brew --cache)
export LOGIN_FILE="~/.bash_profile" # for bash, or edit .zshrc for zsh
echo 'export CUDA_HOME=/usr/local/cuda' >> $LOGIN_FILE
echo 'export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:$CUDA_HOME/lib"' >> $LOGIN_FILE
echo 'export PATH="$CUDA_HOME/bin:$PATH"' >> $LOGIN_FILE
source $LOGIN_FILE
# Get cuDNN 5 for Mac OS X, requires an account:
# https://developer.nvidia.com/rdp/cudnn-download
export CUDNN_URL="http://developer.download.nvidia.com/compute/machine-learning/cudnn/secure/v5.1/rc/7.5/cudnn-7.5-osx-x64-v5.1-rc.tgz?autho=1467769140_909204ac7ea1cfd63896572d4ee35029&file=cudnn-7.5-osx-x64-v5.1-rc.tgz"
wget $CUDNN_URL
tar -xzf cudnn-*-osx-x64-v*.tgz
sudo mv cuda/include/cudnn.h /Developer/NVIDIA/CUDA-7.5/include/
sudo mv cuda/lib/libcudnn* /Developer/NVIDIA/CUDA-7.5/lib
sudo ln -s /Developer/NVIDIA/CUDA-7.5/lib/libcudnn* /usr/local/cuda/lib/
cd /usr/local/cuda/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery # ensure cuda 7.5 and take note of compute capability
cd ~
git clone -b r0.9 https://github.com/tensorflow/tensorflow
cd tensorflow
# configure with:
# default gcc
# CUDA SDK version 7.5
# default path
# cuDNN version 5
# default path
# for GeForce GT 650M and GeForce GT 750M the CUDA compute capability value is 3.0
./configure
bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
pip install /tmp/tensorflow_pkg/tensorflow-0.9.0-py2-none-any.whl
cd ~
rm -rf tensorflow cuda cudnn*.tgz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment