OS X GPU is now supported in Tensorflow

2018/12/16 postscript

It seems that the official GPU support for OS X has disappeared before I knew it, so if you still want to use GPU, this document may be helpful. Tensorflow 1.6 on macOS High Sierra 10.13.3 with GPU Acceleration (without disabling SIP)

2017/2/17 postscript

It's easy to install from Tensorflow 1.0.0, so it's recommended to follow the official documentation. https://www.tensorflow.org/install/install_mac

#cuda8.0
$ brew upgrade
$ brew install coreutils
$ brew cask install cuda

#cuDNN v5.1 Download Library for OS X and each/user/local/cuda/How to copy

##.bash_profile
#export CUDA_HOME=/usr/local/cuda
#export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib"
#export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:$CUDA_HOME/lib"
#export PATH="$CUDA_HOME/bin:$PATH"
#I can do it for the time being, but I will put a link because a warning will appear
$ cd /usr/local/cuda/lib
$ sudo ln -s libcuda.dylib libcuda.1.dylib

$ easy_install --upgrade pip
$ easy_install --upgrade six 
$ pip install tensorflow-gpu

Below, this article

In the official Tensorflow repository, Issue # 664 commit: Enable building with CUDA support on Mac OS X / tensorflow / commit / 59faa82c072c473551b25695431fab613675bf24) has been merged.

Now that you can officially use the GPU on your Mac, let's install it immediately.

Reference: [How to compile tensorflow with CUDA support on OSX (Updated 2nd May 2016)](https://medium.com/@fabmilo/how-to-compile-tensorflow-with-cuda-support-on-osx-fd27108e27e1 # .tudz318t1)

$ brew update
$ brew cask info cuda 
cuda: 7.5.20
$ bazel version
Build label: 0.2.1-homebrew      

Download cuDNN from NVIDIA https://developer.nvidia.com/cudnn Tensorflow version 0.8 is cuDNN v5, version 0.7 and below is v4 I downloaded cudnn-7.5-osx-x64-v5.0-rc.tgz.

Unzip the file and move it to the specified position

$tar xzvf ~/Downloads/cudnn-7.5-osx-x64-v5.0-rc.tgz
$sudo mv -v cuda/lib/libcudnn* /usr/local/cuda/lib
$sudo mv -v cuda/include/cudnn.h /usr/local/cuda/include

In .bash_profile export DYLD_LIBRARY_PATH=/usr/local/cuda/lib:$DYLD_LIBRARY_PATH Add

$cd Tensorflow repo
$ git pull
$ git checkout master
$ TF_UNOFFICIAL_SETTING=1 ./configure            
Please specify the location of python. [Default is /usr/local/bin/python]:
Do you wish to build TensorFlow with GPU support? [y/N] y 
GPU support will be enabled for TensorFlow                                                                                      
Please specify which gcc nvcc should use as the host compiler. [Default is /usr/bin/gcc]:
Please specify the Cuda SDK version you want to use, e.g. 7.0. [Leave empty to use system default]: 7.5 
Please specify the location where CUDA 7.5 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]:
Please specify the Cudnn version you want to use. [Leave empty to use system default]: 5 
Please specify the location where cuDNN 5 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda]: 
Please specify a list of comma-separated Cuda compute capabilities you want to build with.
You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus.                                  
Please note that each additional compute capability significantly increases your build time and binary size. [Default is: "3.5,5.2"]: 3.0
Setting up Cuda include                                                                                                         
Setting up Cuda lib                                                                                                             
Setting up Cuda bin                                                                                                             
Setting up Cuda nvvm                                                                                                            
Setting up CUPTI include                                                                                                        
Setting up CUPTI lib64                                                                                                          
Configuration finished                                                                                                          

$ bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package 
...It takes quite a while...
$ bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
$ pip install /tmp/tensorflow_pkg/tensorflow-0.8.0-py2-none-any.whl

It may be possible to buy such a thing. BizonBOX 2 (External Graphics Card for Mac)

Recommended Posts

OS X GPU is now supported in Tensorflow
[Is it explosive !?] Setup for using the GPU version of Tensorflow on OS X
Partially read parameters in old TensorFlow 1.x
Multivariate LSTM and data preprocessing in TensorFlow 2.x
Installing TensorFlow 0.11.0rc2 on OS X El Capitan (10.11.6)
Install LightGBM in an OS X virtualenv environment
TensorFlow 2.1 is here!
Easy 3 minutes TensorBoard in Google Colab (using TensorFlow 2.x)
When "ERROR: HTTP is not supported." Is displayed in mpsyt
Gtk-ERROR **: 04: 28: 17.451: GTK + 2.x symbols detected. Using GTK + 2.x and GTK + 3 in the same process is not supported error