Skip to content

Instantly share code, notes, and snippets.

@to-bee
Last active January 11, 2021 01:24
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save to-bee/6d19b7fa0d68ee97407591de1586da62 to your computer and use it in GitHub Desktop.
Save to-bee/6d19b7fa0d68ee97407591de1586da62 to your computer and use it in GitHub Desktop.
Build tensorflow with gpu support on OSX Sierra
disable sip in recovery mode
start recovery mode with Cmd + R on startup
start terminal
csrutil disable
download and install cuda 8
download cuDNN v6.0 for cuda 8 (register first)
install xcode 7.2
current xcode version is not supported
https://srikanthpagadala.github.io/notes/2016/11/07/enable-gpu-support-for-tensorflow-on-macos
• download Xcode 7.2.1 from the apple developer website
• create a new directory /Applications/XCode7.2.1/
• copy the entire XCode.App inside /Applications/XCode7.2.1
• run sudo xcode-select -s /Applications/XCode7.2.1/Xcode.app/
move cuda libs
cd /Users/tobi/Downloads
sudo mv -v cuda/lib/libcudnn* /usr/local/cuda/lib
sudo mv -v cuda/include/cudnn.h /usr/local/cuda/include
clone git
git clone --recurse-submodules https://github.com/tensorflow/tensorflow
git checkout remotes/origin/r1.1
add to .bash_profile
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=$CUDA_HOME/bi:$DYLD_LIBRARY_PATH:$PATH
activate venv
source /Users/tobi/python3/bin/activate
uninstall old tensorflow version
pip uninstall tensorflow
pip uninstall tensorflow-gpu
avoid missing rpath error
https://github.com/tensorflow/tensorflow/issues/4187
cd /Users/tobi/tensorflow/
touch -t YYYYMMDDhhmm.SS genrule-setup.sh
configure
check your gpu prerequisites:
http://stackoverflow.com/questions/33651810/the-minimum-required-cuda-capability-is-3-5
https://developer.nvidia.com/cuda-gpus?nocache=1492985895
TF_UNOFFICIAL_SETTING=1 ./configure
build
bazel build --config=cuda --config=opt --action_env PATH --action_env LD_LIBRARY_PATH --action_env DYLD_LIBRARY_PATH //tensorflow/tools/pip_package:build_pip_package
@andrewrech
Copy link

andrewrech commented Jun 28, 2017

Thank you for posting this! Have you attempted to build r1.2, despite no official support?

@alvaromuir
Copy link

Thanks for this, minor typo in environmental variables

export PATH=$CUDA_HOME/bin:$DYLD_LIBRARY_PATH:$PATH

@AAyse
Copy link

AAyse commented Oct 3, 2017

Hi,

I am exactly doing the steps but I am failing on the last step of the .configure, I am getting two errors:

  1. error loading package 'tensorflow/stream_executor': Encountered error while reading extension file 'cuda/build_defs.bzl': no such package '@local_config_cuda//cuda': Traceback (most recent call last):
  2. Auto-Configuration Error: Cannot find line containing '#define CUDNN_MAJOR' in /usr/local/cuda/include/cudnn.h

How can I solve this, any suggests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment