Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MatthiasWinkelmann/41dd42b07f8bd794aa462f3b9712c018 to your computer and use it in GitHub Desktop.
Save MatthiasWinkelmann/41dd42b07f8bd794aa462f3b9712c018 to your computer and use it in GitHub Desktop.
Tensorflow 1.7 Mac OS Sierra 10.12 GPU Support

Tensorflow

System information

  • OS - Sierra 10.12
  • Tensorflow - 1.7.0
  • Xcode command line tools - 8.2 (Download from here: Xcode - Support - Apple Developer & Switch to different clang version: sudo xcode-select --switch/Library/Developer/CommandLineTools & check version: clang -v)
  • Cmake - 3.11
  • Bazel - 0.11.1
  • CUDA - 8.0.61
  • cuDNN - 7

Requirements

  • sudo pip install six numpy wheel
  • brew install coreutils
  • brew install gcc

We install gcc for libgomp. You may need to add a link to it, i. e. ln -s /usr/local/Cellar/gcc/7.2.0_1/lib/gcc/7/libgomp.dylib /usr/local/lib/libgomp.dylib

Patching Tensorflow

You can check out my MacOS GPU branch at https://github.com/MatthiasWinkelmann/tensorflow, but it may not always be up-to-date with tensorflow. The basic changes are:

Replace all occurances of align(sizeof(T)) with align(sizeof(T) > 16 ? sizeof(T) : 16)

This currently affects the following files:

  • tensorflow/core/kernels/bucketize_op_gpu.cu.cc
  • tensorflow/core/kernels/concat_lib_gpu_impl.cu.cc
  • tensorflow/core/kernels/depthwise_conv_op_gpu.cu.cc
  • tensorflow/core/kernels/split_lib_gpu.cu.cc

For example, extern shared __align(sizeof(T))__ unsigned char smem[]; => extern shared __align__(sizeof(T) > 16 ? sizeof(T) : 16) unsigned char smem[];

constexpr

Change:

tensorflow/core/framework/variant.h:

class Variant {
public:
 //constexpr Variant() noexcept = default;
 Variant() noexcept = default;

Steps:

  • Run ./configure
  • Add following paths:
    • export CUDA_HOME=/usr/local/cuda
    • export DYLD_LIBRARY_PATH=/usr/local/cuda/lib
  • bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
  • bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
  • pip install /tmp/tensorflow_pkg/*.whl (File name depends on tensorflow version and python version)
@jvence
Copy link

jvence commented Oct 4, 2018

Any chance to upgrade this to CUDA 10 and Mac OS 10.14 and perhaps latest version of tensorflow? Thanks for all your help

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