Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Tensorflow 1.4 Mac OS High Sierra 10.13 GPU Support

Tensorflow

System information

  • OS - High Sierra 10.13
  • Tensorflow - 1.4
  • 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.7
  • Bazel - 0.7.0
  • CUDA - 9
  • cuDNN - 7

Requirements

  • sudo pip install six numpy wheel
  • brew install coreutils

Step-by-step guide

Remove all align(sizeof(T)) from following files:

  • tensorflow/core/kernels/depthwise_conv_op_gpu.cu.cc

  • tensorflow/core/kernels/split_lib_gpu.cu.cc

  • tensorflow/core/kernels/concat_lib_gpu.impl.cu.cc

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

Steps:

  • Disable SIP (in recovery mode enter command: csrutil disable)
  • ./configure (Find CUDA compute value from https://developer.nvidia.com/cuda-gpus)
    Smit-Shilu:tensorflow-build smitshilu$ ./configure
    You have bazel 0.7.0-homebrew installed.
    Please specify the location of python. [Default is /Users/smitshilu/anaconda3/bin/python]:
    
    Found possible Python library paths:
      /Users/smitshilu/anaconda3/lib/python3.6/site-packages
    Please input the desired Python library path to use.  Default is [/Users/smitshilu/anaconda3/lib/python3.6/site-packages]
    
    Do you wish to build TensorFlow with Google Cloud Platform support? [Y/n]: n
    No Google Cloud Platform support will be enabled for TensorFlow.
    
    Do you wish to build TensorFlow with Hadoop File System support? [Y/n]: n
    No Hadoop File System support will be enabled for TensorFlow.
    
    Do you wish to build TensorFlow with Amazon S3 File System support? [Y/n]: n
    No Amazon S3 File System support will be enabled for TensorFlow.
    
    Do you wish to build TensorFlow with XLA JIT support? [y/N]: n
    No XLA JIT support will be enabled for TensorFlow.
    
    Do you wish to build TensorFlow with GDR support? [y/N]: n
    No GDR support will be enabled for TensorFlow.
    
    Do you wish to build TensorFlow with VERBS support? [y/N]: n
    No VERBS support will be enabled for TensorFlow.
    
    Do you wish to build TensorFlow with OpenCL support? [y/N]: n
    No OpenCL support will be enabled for TensorFlow.
    
    Do you wish to build TensorFlow with CUDA support? [y/N]: y
    CUDA support will be enabled for TensorFlow.
    
    Please specify the CUDA SDK version you want to use, e.g. 7.0. [Leave empty to default to CUDA 8.0]: 9.0
    
    Please specify the location where CUDA 9.0 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 default to cuDNN 6.0]: 7
    
    Please specify the location where cuDNN 7 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]6.1
    
    Do you want to use clang as CUDA compiler? [y/N]:
    nvcc will be used as CUDA compiler.
    
    Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]:
    
    Do you wish to build TensorFlow with MPI support? [y/N]:
    No MPI support will be enabled for TensorFlow.
    
    Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]:
    
    Add "--config=mkl" to your bazel command to build with MKL support.
    Please note that MKL on MacOS or windows is still not supported.
    If you would like to use a local MKL instead of downloading, please set the environment variable "TF_MKL_ROOT" every time before build.
    Configuration finished
    
  • Add following paths:
    • export CUDA_HOME=/usr/local/cuda
    • export DYLD_LIBRARY_PATH=/Users/USERNAME/lib:/usr/local/cuda/lib:/usr/local/cuda/extras/CUPTI/lib (Replace USERNAME with your machine username)
    • export LD_LIBRARY_PATH=$DYLD_LIBRARY_PATH
    • export PATH=$DYLD_LIBRARY_PATH:$PATH
  • Start 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
    
  • Generate a wheel for installation
    bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
    
  • Install tensorflow wheel
    sudo pip install /tmp/tensorflow_pkg/tensorflow-1.4.0rc1-cp36-cp36m-macosx_10_7_x86_64.whl (File name depends on tensorflow version and python version)
    
@yunhwankim2

This comment has been minimized.

Copy link

commented Nov 24, 2017

Thank you for sharing your experience.
It seems that CUDA toolkit does not support 10.13 (High Sierra) yet because there is no option for 10.13 in CUDA toolkit download page (https://developer.nvidia.com/cuda-downloads).
Does GPU in your machine works well when using Tensorflow? Or is there other way to enable CUDA to work in High Sierra?
Many thanks in advance.

@ilophy

This comment has been minimized.

Copy link

commented Nov 27, 2017

@smitshilu

This comment has been minimized.

Copy link
Owner Author

commented Nov 28, 2017

@yunhwankim2 yes tensorflow works good in my machine using GPU, I followed same steps I mentioned above

@smitshilu

This comment has been minimized.

Copy link
Owner Author

commented Nov 28, 2017

@ilophy what challenges are you facing?

@Altares

This comment has been minimized.

Copy link

commented Nov 29, 2017

Nicely done! Thank you!

@yunhwankim2

This comment has been minimized.

Copy link

commented Nov 30, 2017

@smitshilu Oh, I see. I still stick to Sierra now, but I'll think of upgrading to High Sierra soon. Thank you!

@coocoorhin

This comment has been minimized.

Copy link

commented Dec 4, 2017

hi, i am following your guide till the building.
i am having this error message

Ziyaos-iMac:tensorflow ziyaowang$ 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
ERROR: Skipping '//tensorflow/tools/pip_package:build_pip_package': error loading package 'tensorflow/tools/pip_package': Encountered error while reading extension file 'cuda/build_defs.bzl': no such package '@local_config_cuda//cuda': Traceback (most recent call last):
	File "/Users/ziyaowang/Documents/tensorflow/third_party/gpus/cuda_configure.bzl", line 1042
		_create_local_cuda_repository(repository_ctx)
	File "/Users/ziyaowang/Documents/tensorflow/third_party/gpus/cuda_configure.bzl", line 923, in _create_local_cuda_repository
		_find_libs(repository_ctx, cuda_config)
	File "/Users/ziyaowang/Documents/tensorflow/third_party/gpus/cuda_configure.bzl", line 569, in _find_libs
		_find_cuda_lib("cuda", repository_ctx, cpu_value, cud...)
	File "/Users/ziyaowang/Documents/tensorflow/third_party/gpus/cuda_configure.bzl", line 503, in _find_cuda_lib
		auto_configure_fail(("Cannot find cuda library %s" %...))
	File "/Users/ziyaowang/Documents/tensorflow/third_party/gpus/cuda_configure.bzl", line 129, in auto_configure_fail
		fail(("\n%sCuda Configuration Error:%...)))

Cuda Configuration Error: Cannot find cuda library libcuda.dylib
WARNING: Target pattern parsing failed.
ERROR: error loading package 'tensorflow/tools/pip_package': Encountered error while reading extension file 'cuda/build_defs.bzl': no such package '@local_config_cuda//cuda': Traceback (most recent call last):
	File "/Users/ziyaowang/Documents/tensorflow/third_party/gpus/cuda_configure.bzl", line 1042
		_create_local_cuda_repository(repository_ctx)
	File "/Users/ziyaowang/Documents/tensorflow/third_party/gpus/cuda_configure.bzl", line 923, in _create_local_cuda_repository
		_find_libs(repository_ctx, cuda_config)
	File "/Users/ziyaowang/Documents/tensorflow/third_party/gpus/cuda_configure.bzl", line 569, in _find_libs
		_find_cuda_lib("cuda", repository_ctx, cpu_value, cud...)
	File "/Users/ziyaowang/Documents/tensorflow/third_party/gpus/cuda_configure.bzl", line 503, in _find_cuda_lib
		auto_configure_fail(("Cannot find cuda library %s" %...))
	File "/Users/ziyaowang/Documents/tensorflow/third_party/gpus/cuda_configure.bzl", line 129, in auto_configure_fail
		fail(("\n%sCuda Configuration Error:%...)))

Cuda Configuration Error: Cannot find cuda library libcuda.dylib
INFO: Elapsed time: 0.210s
FAILED: Build did NOT complete successfully (0 packages loaded)
    currently loading: tensorflow/tools/pip_package

where i have Cuda toolkits installed by default at /Developer/NVIDIA/CUDA-9.0
so in my path i have as follows:

export CUDA_HOME=/Developer/NVIDIA/CUDA-9.0
export DYLD_LIBRARY_PATH=/Users/ziyaowang/lib:/Developer/NVIDIA/CUDA-9.0/lib:/Developer/NVIDIA/CUDA-9.0/extras/CUPTI/lib
export LD_LIBRARY_PATH=$DYLD_LIBRARY_PATH
export PATH=$DYLD_LIBRARY_PATH:$PATH

i am pretty noob in this, do you mind helping this noob here.

@smitshilu

This comment has been minimized.

Copy link
Owner Author

commented Dec 4, 2017

@coocoorhin you should provide path /usr/local/cuda as in ./configuration we are providing that path which is verified by the installer

@coocoorhin

This comment has been minimized.

Copy link

commented Dec 5, 2017

@smitshilu hmm i don't get it. the default installation is to /Developer/NVIDIA/CUDA-9.0 and not /usr/local/cuda.

@maxiaodong97

This comment has been minimized.

Copy link

commented Dec 5, 2017

thanks man you saved my a day!

@smitshilu

This comment has been minimized.

Copy link
Owner Author

commented Dec 6, 2017

@coocoorhin what path are you passing while you are running ./configuration? If you check in this line
Please specify the location where CUDA 9.0 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]:
Defult path is /usr/local/cuda so export the same path even default installation path is different

@gatagat

This comment has been minimized.

Copy link

commented Dec 7, 2017

Did anybody see an OpenMP-related linking failure?

$ bazel build --verbose_failures --config=opt --config=cuda --action_env PATH --action_env LD_LIBRARY_PATH --action_env DYLD_LIBRARY_PATH //tensorflow/tools/pip_package:build_pip_package
'//tensorflow/python:_pywrap_tensorflow_internal.so' failed (Exit 1): crosstool_wrapper_driver_is_not_gcc failed...
...
clang: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]
ld: library not found for -lgomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Target //tensorflow/tools/pip_package:build_pip_package failed to build
INFO: Elapsed time: 1.017s, Critical Path: 0.19s
FAILED: Build did NOT complete successfully
@smitshilu

This comment has been minimized.

Copy link
Owner Author

commented Dec 7, 2017

@gatagat you can download from here.

@masasys

This comment has been minimized.

Copy link

commented Dec 8, 2017

Information on OpenMP failure was here.

https://medium.com/@mattias.arro/installing-tensorflow-1-2-from-sources-with-gpu-support-on-macos-4f2c5cab8186
In my case I commented out line 98 of tensorflow/third_party/gpus/cuda/BUILD.tpl, which contained linkopts = [“-lgomp”] (but the location of the line might obviously change).

It was in line 112 in Tensorflow 1.4

@archenroot

This comment has been minimized.

Copy link

commented Dec 8, 2017

Remove all align(sizeof(T)) from following files:
tensorflow/core/kernels/depthwise_conv_op_gpu.cu.cc
tensorflow/core/kernels/split_lib_gpu.cu.cc
tensorflow/core/kernels/concat_lib_gpu.impl.cu.cc
For example, extern shared align(sizeof(T)) unsigned char smem[]; => extern shared unsigned char smem[];

Could you elaborate why to replacing these artefacts, is it required to do PR back to tensorflow?

@smitshilu

This comment has been minimized.

Copy link
Owner Author

commented Dec 8, 2017

@archenroot I am not sure about that as I did not encountered error while installing on the windows or Rpi So, I think it is something related to OSX GPU installation

@bingo619

This comment has been minimized.

Copy link

commented Dec 9, 2017

Thanks very much. Spent one day on setting this up with my egpu+1080ti

Recommend this tool to set the global variables so that Pycharm works as well.

https://github.com/hschmidt/EnvPane

@carlomx

This comment has been minimized.

Copy link

commented Dec 13, 2017

Hi, I'm trying to follow the steps but I'm getting an error while building:

...
INFO: From ProtoCompile tensorflow/core/example/example.pb.cc:
bazel-out/local_darwin-py3-opt/genfiles/external/protobuf_archive/src: warning: directory does not exist.
INFO: From ProtoCompile tensorflow/core/debug/debug_service.pb.cc:
bazel-out/local_darwin-py3-opt/genfiles/external/protobuf_archive/src: warning: directory does not exist.
bazel-out/local_darwin-py3-opt/genfiles/external/protobuf_archive/src: warning: directory does not exist.
bazel-out/local_darwin-py3-opt/genfiles/external/protobuf_archive/src: warning: directory does not exist.
ERROR: /Users/yanezc/tensorflow_to_compile/tensorflow/tensorflow/cc/BUILD:509:1: Executing genrule //tensorflow/cc:remote_fused_graph_ops_genrule failed (Aborted): bash failed: error executing command /bin/bash -c ... (remaining 1 argument(s) skipped).
dyld: Library not loaded: @rpath/libcudart.9.0.dylib
  Referenced from: /private/var/tmp/_bazel_yanezc/ff855679b4fe3abb0e55ea369530a708/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/cc/ops/remote_fused_graph_ops_gen_cc
  Reason: image not found
/bin/bash: line 1: 58788 Abort trap: 6           bazel-out/host/bin/tensorflow/cc/ops/remote_fused_graph_ops_gen_cc bazel-out/local_darwin-py3-opt/genfiles/tensorflow/cc/ops/remote_fused_graph_ops.h bazel-out/local_darwin-py3-opt/genfiles/tensorflow/cc/ops/remote_fused_graph_ops.cc , 0
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 58.865s, Critical Path: 19.45s

this is the last commit in the code I checked out before removing align(sizeof(T))

commit 438604fc885208ee05f9eef2d0f2c630e1360a83
Author: Amit Patankar <amitpatankar@google.com>
Date:   Fri Dec 8 12:12:18 2017 +0800

    1.4.1 Release Updates (#15200)

I'm using High Sierra 10.13.2 and here's some information about my environment

iMac-de-Carlo-2:tensorflow yanezc$ clang -v
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin17.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
iMac-de-Carlo-2:tensorflow yanezc$ bazel version
Build label: 0.7.0
Build target: bazel-out/darwin_x86_64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Oct 18 14:25:46 2017 (1508336746)
Build timestamp: 1508336746
Build timestamp as int: 1508336746
iMac-de-Carlo-2:tensorflow yanezc$ echo $CUDA_HOME
/usr/local/cuda
iMac-de-Carlo-2:tensorflow yanezc$ echo $DYLD_LIBRARY_PATH
/Users/yanezc/lib:/usr/local/cuda/lib:/usr/local/cuda/extras/CUPTI/lib
iMac-de-Carlo-2:tensorflow yanezc$ echo $LD_LIBRARY_PATH
/Users/yanezc/lib:/usr/local/cuda/lib:/usr/local/cuda/extras/CUPTI/lib
iMac-de-Carlo-2:tensorflow yanezc$ echo $PATH
/Users/yanezc/anaconda3/bin:/Users/yanezc/lib:/usr/local/cuda/lib:/usr/local/cuda/extras/CUPTI/lib:/usr/local/php5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Mono.framework/Versions/Current/Commands

if I use the --verbose_failures flag I get this:

(cd /private/var/tmp/_bazel_yanezc/ff855679b4fe3abb0e55ea369530a708/execroot/org_tensorflow && \
  exec env - \
    CUDA_TOOLKIT_PATH=/usr/local/cuda \
    CUDNN_INSTALL_PATH=/Users/yanezc/cuda \
    GCC_HOST_COMPILER_PATH=/usr/bin/gcc \
    PATH=/Users/yanezc/anaconda3/bin:/Users/yanezc/lib:/usr/local/cuda/lib:/usr/local/cuda/extras/CUPTI/lib:/usr/local/php5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Mono.framework/Versions/Current/Commands \
    PYTHON_BIN_PATH=/Users/yanezc/anaconda3/bin/python \
    PYTHON_LIB_PATH=/Users/yanezc/anaconda3/lib/python3.6/site-packages \
    TF_CUDA_CLANG=0 \
    TF_CUDA_COMPUTE_CAPABILITIES=5.2 \
    TF_CUDA_VERSION=9.0 \
    TF_CUDNN_VERSION=7 \
    TF_NEED_CUDA=1 \
    TF_NEED_OPENCL=0 \
    TMPDIR=/var/folders/nh/x24vyxvj04s_tgvv7fy1z_4r0000gp/T/ \
  /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh

Does anybody have any idea on what the problem might be?

Thanks

@alexkie007

This comment has been minimized.

Copy link

commented Dec 18, 2017

where is configure which i can use to run

@BorisMansencal

This comment has been minimized.

Copy link

commented Dec 18, 2017

@smitshilu where did you get cuDNN v7 for Mac OS ?
It seems that there is only v6.0 for CUDA 8.0 on https://developer.nvidia.com/rdp/cudnn-download
Thanks.

@smitshilu

This comment has been minimized.

@smitshilu

This comment has been minimized.

Copy link
Owner Author

commented Dec 19, 2017

@alexkie007 It is inside tensorflow directory that you pulled or downloaded from GitHub

@Tweakmind

This comment has been minimized.

Copy link

commented Dec 24, 2017

@smitshilu, this was a huge inspiration, thank you. I couldn't pull it off, so I've been working on it for the past week.

I finally succeeded on Mac. Tensorflow r1.5 on High Sierra, CUDA 9.1, cuDNN 7.0.4. I had to make a lot of changes to my original build. You can check it here. I'm still testing, but so far, it works. This build is based on a Mid-2012 Mac Pro with a 1070. I will swap in a 1080Ti next.

Once I finish testing, I can post the details on github.

Thanks again!

@bossbobster

This comment has been minimized.

Copy link

commented Dec 25, 2017

@Tweakmind, @smitshilu that's great info and very helpful!

I am almost there but I get an error after compiling with cuda. I have High Sierra 10.13.2, cuda 9.1, cudnn 7.0.4.

I still get an error though that I can't overcome...

dyld: Library not loaded: @rpath/libcudart.9.1.dylib

Can you guys guide me here? Full error below

A

ERROR: /Users/bobby/code/sources/tensorflow/tensorflow/contrib/layers/BUILD:36:1: Executing genrule //tensorflow/contrib/layers:sparse_feature_cross_op_pygenrule failed (Aborted): bash failed: error executing command (cd /private/var/tmp/_bazel_bobby/3b68756cb2944dcefba0a29a361f682b/execroot/org_tensorflow && \ exec env - \ CUDA_TOOLKIT_PATH=/usr/local/cuda \ CUDNN_INSTALL_PATH=/usr/local/cuda \ GCC_HOST_COMPILER_PATH=/usr/bin/gcc \ PATH=/Developer/NVIDIA/CUDA-9.1/bin:/Developer/NVIDIA/CUDA-9.0/bin:/Users/bobby/gocode//bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \ PYTHON_BIN_PATH=/usr/bin/python \ PYTHON_LIB_PATH=/Library/Python/2.7/site-packages \ TF_CUDA_CLANG=0 \ TF_CUDA_COMPUTE_CAPABILITIES=3.5,5.2 \ TF_CUDA_VERSION=9.1 \ TF_CUDNN_VERSION=7 \ TF_NEED_CUDA=1 \ TF_NEED_OPENCL_SYCL=0 \ TMPDIR=/var/folders/v8/3c_ch3z53ds_9mkjl97yjtz40000gn/T/ \ /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; bazel-out/host/bin/tensorflow/contrib/layers/gen_sparse_feature_cross_op_py_wrappers_cc , '\'''\'' 0 0 > bazel-out/darwin-opt/genfiles/tensorflow/contrib/layers/ops/gen_sparse_feature_cross_op.py'): bash failed: error executing command (cd /private/var/tmp/_bazel_bobby/3b68756cb2944dcefba0a29a361f682b/execroot/org_tensorflow && \ exec env - \ CUDA_TOOLKIT_PATH=/usr/local/cuda \ CUDNN_INSTALL_PATH=/usr/local/cuda \ GCC_HOST_COMPILER_PATH=/usr/bin/gcc \ PATH=/Developer/NVIDIA/CUDA-9.1/bin:/Developer/NVIDIA/CUDA-9.0/bin:/Users/bobby/gocode//bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \ PYTHON_BIN_PATH=/usr/bin/python \ PYTHON_LIB_PATH=/Library/Python/2.7/site-packages \ TF_CUDA_CLANG=0 \ TF_CUDA_COMPUTE_CAPABILITIES=3.5,5.2 \ TF_CUDA_VERSION=9.1 \ TF_CUDNN_VERSION=7 \ TF_NEED_CUDA=1 \ TF_NEED_OPENCL_SYCL=0 \ TMPDIR=/var/folders/v8/3c_ch3z53ds_9mkjl97yjtz40000gn/T/ \ /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; bazel-out/host/bin/tensorflow/contrib/layers/gen_sparse_feature_cross_op_py_wrappers_cc , '\'''\'' 0 0 > bazel-out/darwin-opt/genfiles/tensorflow/contrib/layers/ops/gen_sparse_feature_cross_op.py') dyld: Library not loaded: @rpath/libcudart.9.1.dylib Referenced from: /private/var/tmp/_bazel_bobby/3b68756cb2944dcefba0a29a361f682b/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/contrib/layers/gen_sparse_feature_cross_op_py_wrappers_cc Reason: image not found

Thanks!

@bossbobster

This comment has been minimized.

Copy link

commented Dec 26, 2017

Just FYI, I managed to compile by creating symbolic links to most CUDA these libraries in /usr/local/lib

@PrzemyslawJaworski

This comment has been minimized.

Copy link

commented Dec 28, 2017

Hi,

I receive the following error messages during linking process:


clang: warning: argument unused during compilation: '-pthread'
ERROR: /Users/myuser/Downloads/tensorflow/tensorflow/python/BUILD:2953:1: Linking of rule '//tensorflow/python:_pywrap_tensorflow_internal.so' failed (Exit 1)
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'
ld: library not found for -lgomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.

My components:
Hardware: Macbook Pro Retina (mid 2012)
OS: High Sierra 10.13.2
CUDA Driver Version: 387.99
GPU Driver Version: 378.10.10.10.25.102
CUDNN7
CUDA9
bazel 0.9.0 (compiling with --incompatible_load_argument_is_label=false option to avoid errors)
clang 8.0.0 (clang-800.0.42.1)
cmake version 3.10.0

Any suggestions?

@adithyabsk

This comment has been minimized.

Copy link

commented Dec 30, 2017

@technic2017 take a look at this. It is a previous version but in it he suggests:

TensorFlow 1.2 / 1.3 expects a C library called OpenMP, which is not available in the current Apple Clang. It should speed up multithreaded TensorFlow on multi-CPU machines, but it will also compile without it. We could try to build TensorFlow with gcc 4 (which I didn’t manage), or simply remove the line that includes OpenMP from the build file. In my case I commented out line 98 of tensorflow/third_party/gpus/cuda/BUILD.tpl, which contained linkopts = [“-lgomp”] (but the location of the line might obviously change). Some people had issues with zmuldefs, but I assume that was with earlier versions; thanks to udnaan for pointing out that it’s OK to comment out these lines.

I was having the same issue and did the above and it now works.

@zlf0625

This comment has been minimized.

Copy link

commented Jan 3, 2018

@bossbobster I'm using zsh so I run source ~/.bash_profile first

@sxhysj

This comment has been minimized.

Copy link

commented Jan 6, 2018

I follow the guide. But encountered:
"//tensorflow/python:_pywrap_tensorflow_internal.so" failed

Have I written custom code?
I removed all align(sizeof(T)) from following files:
tensorflow/core/kernels/depthwise_conv_op_gpu.cu.cc
tensorflow/core/kernels/split_lib_gpu.cu.cc
tensorflow/core/kernels/concat_lib_gpu.impl.cu.cc

OS Platform and Distribution
Mac OS X 10.13.2

TensorFlow installed from
source 1.4, date: 20180104

TensorFlow version
1.4

Bazel version
0.9.0-homebrew

CUDA/cuDNN version
9.1/7.0

GPU model and memory
GTX 1080Ti, 11GB

Exact command to reproduce
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
@smitshilu

@xlvecle

This comment has been minimized.

Copy link

commented Jan 13, 2018

I follow the guide and put it over. I built a repo with my compiled files to help people install tensorflow-gpu on macOS.
https://github.com/xlvecle/tensorflow-macOS-gpu
@smitshilu Big thanks to you 👍

@lpla

This comment has been minimized.

Copy link

commented Jan 16, 2018

@xlvecle Could you try to PR the patch of your fork to the main Tensorflow repository?

@ghost

This comment has been minimized.

Copy link

commented Jan 24, 2018

My components:

OS Platform and Distribution
Mac OS X 10.13.2

TensorFlow installed from
source 1.4, date: 20180104

TensorFlow version
1.4

Bazel version
0.9.0-homebrew

CUDA/cuDNN version
9.0/7.0

GPU model and memory
GTX 1080Ti, 11GB

I run this code!
bazel build -c opt config=cuda --spawn_strategy=standalone --verbose_failures --incompatible_load_argument_is_label=false //tensorflow/tools/pip_package:build_pip_package

But I receive error...

WARNING: /Users/name/tensorflow/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:exporter': No longer supported. Switch to SavedModel immediately.
WARNING: /Users/name/tensorflow/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:gc': No longer supported. Switch to SavedModel immediately.
INFO: Analysed target //tensorflow/tools/pip_package:build_pip_package (203 packages loaded).
INFO: Found 1 target...
INFO: From Compiling external/protobuf_archive/src/google/protobuf/compiler/js/embed.cc [for host]:
external/protobuf_archive/src/google/protobuf/compiler/js/embed.cc:37:12: warning: unused variable 'output_file' [-Wunused-const-variable]
const char output_file[] = "well_known_types_embed.cc";
          ^
1 warning generated.
ERROR: /private/var/tmp/_bazel_name/cb03877c162e6674f9f78b12c9c0e645/external/protobuf_archive/BUILD:265:1: Linking of 
rule '@protobuf_archive//:js_embed' failed (Exit 1): cc_wrapper.sh failed: error executing command 
(cd /private/var/tmp/_bazel_name/cb03877c162e6674f9f78b12c9c0e645/execroot/org_tensorflow && \
exec env - \
  APPLE_SDK_PLATFORM='' \
  APPLE_SDK_VERSION_OVERRIDE='' \
  LD_LIBRARY_PATH=/Users/name/lib:/usr/local/cuda/lib:/usr/local/cuda/extras/CUPTI/lib:/Developer/NVIDIA/CUDA-9.0/lib \
  PATH=/Users/name/miniconda3/envs/py3/bin:/usr/bin:/Developer/NVIDIA/CUDA-9.0/bin:/Users/name/lib:/usr/local/cuda/lib:/usr/local/cuda/extras/CUPTI/lib:/Developer/NVIDIA/CUDA-9.0/lib:/Users/name/miniconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin \
  TMPDIR=/var/folders/q3/4n8988wn2cx_gz7g3d7hjhv80000gn/T/ \
  XCODE_VERSION_OVERRIDE=9.2.0 \
external/local_config_cc/cc_wrapper.sh -fobjc-link-runtime -Wl,-S -o bazel-out/host/bin/external/protobuf_archive/js_embed bazel-out/host/bin/external/protobuf_archive/_objs/js_embed/external/protobuf_archive/src/google/protobuf/compiler/js/embed.o -headerpad_max_install_names -lc++ -no-canonical-prefixes)
gcc: error: unrecognized command line option '-fobjc-link-runtime'; did you mean '-fgnu-runtime'?
Target //tensorflow/tools/pip_package:build_pip_package failed to build
INFO: Elapsed time: 122.295s, Critical Path: 1.23s 
FAILED: Build did NOT complete successfully

Please give me some advices!

@smitshilu

This comment has been minimized.

Copy link
Owner Author

commented Jan 24, 2018

@km4342 use Xcode version 8.2 or download 8.2 command line tool and use that one while installing

@ghost

This comment has been minimized.

Copy link

commented Jan 25, 2018

Here the output I get...

WARNING: /Users/name/tensorflow/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:exporter': No longer supported. Switch to SavedModel immediately.
WARNING: /Users/name/tensorflow/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:gc': No longer supported. Switch to SavedModel immediately.
INFO: Analysed target //tensorflow/tools/pip_package:build_pip_package (221 packages loaded).
INFO: Found 1 target...
ERROR: /private/var/tmp/_bazel_name/cb03877c162e6674f9f78b12c9c0e645/external/protobuf_archive/BUILD:135:1: C++ compilation of rule '@protobuf_archive//:protobuf' failed (Exit 1)
gcc: error: unrecognized command line option '-fcolor-diagnostics'
gcc: error: unrecognized command line option '-Wthread-safety'; did you mean '-fthread-jumps'?
gcc: error: unrecognized command line option '-Wself-assign'; did you mean '-Wcast-align'?
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 57.583s, Critical Path: 0.30s
FAILED: Build did NOT complete successfully
@smitshilu

This comment has been minimized.

Copy link
Owner Author

commented Jan 26, 2018

@km4342 use --verbose_failures with build command to see the errors and post them here

@ur001

This comment has been minimized.

Copy link

commented Jan 27, 2018

INFO: From Compiling tensorflow/contrib/image/kernels/image_ops_gpu.cu.cc:
external/eigen_archive/unsupported/Eigen/CXX11/../../../Eigen/src/Core/arch/CUDA/Half.h(508): error: explicit specialization of class "std::__1::numeric_limits<Eigen::half>" must precede its first use (
(388): here)

./tensorflow/core/lib/core/status.h(32): warning: attribute "warn_unused_result" does not apply here

1 error detected in the compilation of "/private/var/tmp/_bazel_ur001/d056a262d08dcd961e10bfa6c5eb8414/execroot/org_tensorflow/tmp74d_f74101d44411e159/tmpxft_000097ed_00000000-6_image_ops_gpu.cu.cpp1.ii".
ERROR: /Users/ur001/Dropbox/Projects/SRC/-other-/-notsites-/netology/tensorflow/tensorflow/contrib/image/BUILD:22:1: output 'tensorflow/contrib/image/_objs/python/ops/_image_ops_gpu/tensorflow/contrib/image/kernels/image_ops_gpu.cu.pic.o' was not created
ERROR: /Users/ur001/Dropbox/Projects/SRC/-other-/-notsites-/netology/tensorflow/tensorflow/contrib/image/BUILD:22:1: not all outputs were created or valid
Target //tensorflow/tools/pip_package:build_pip_package failed to build
INFO: Elapsed time: 5.010s, Critical Path: 4.04s
FAILED: Build did NOT complete successfully

OS - High Sierra 10.13.2
Tensorflow - 1.5
CUDA - 9.1
cuDNN - 7

@ghost

This comment has been minimized.

Copy link

commented Jan 29, 2018

@smitshilu
Input
bazel build --verbose_failures //tensorflow/tools/pip_package:build_pip_package
Output

ERROR: /private/var/tmp/_bazel_name/cb03877c162e6674f9f78b12c9c0e645/external/local_config_sycl/sycl/BUILD:4:1: First argument of 'load' must be a label and start with either '//', ':', or '@'. Use --incompatible_load_argument_is_label=false to temporarily disable this check.
ERROR: /private/var/tmp/_bazel_name/cb03877c162e6674f9f78b12c9c0e645/external/local_config_sycl/sycl/BUILD:6:1: First argument of 'load' must be a label and start with either '//', ':', or '@'. Use --incompatible_load_argument_is_label=false to temporarily disable this check.
ERROR: /private/var/tmp/_bazel_name/cb03877c162e6674f9f78b12c9c0e645/external/local_config_sycl/sycl/BUILD:30:9: Traceback (most recent call last):
	File "/private/var/tmp/_bazel_name/cb03877c162e6674f9f78b12c9c0e645/external/local_config_sycl/sycl/BUILD", line 27
		cc_library(name = "syclrt", srcs = [sycl_libr...")], <3 more arguments>)
	File "/private/var/tmp/_bazel_name/cb03877c162e6674f9f78b12c9c0e645/external/local_config_sycl/sycl/BUILD", line 30, in cc_library
		sycl_library_path
name 'sycl_library_path' is not defined
ERROR: /private/var/tmp/_bazel_name/cb03877c162e6674f9f78b12c9c0e645/external/local_config_sycl/sycl/BUILD:39:1: Target '@local_config_sycl//sycl:using_sycl' contains an error and its package is in error and referenced by '@local_config_sycl//sycl:sycl'
ERROR: /Users/name/tensorflow/third_party/eigen3/BUILD:20:1: Target '@local_config_sycl//sycl:sycl' contains an error and its package is in error and referenced by '//third_party/eigen3:eigen3'
ERROR: Analysis of target '//tensorflow/tools/pip_package:build_pip_package' failed; build aborted: Loading failed
INFO: Elapsed time: 10.605s
FAILED: Build did NOT complete successfully (80 packages loaded)
    currently loading: tensorflow/core ... (5 packages)

and, I try
bazel build --verbose_failures --incompatible_load_argument_is_label=false //tensorflow/tools/pip_package:build_pip_package

output

WARNING: /Users/name/tensorflow/tensorflow/core/BUILD:1781:1: in includes attribute of cc_library rule //tensorflow/core:framework_headers_lib: '../../external/nsync/public' resolves to 'external/nsync/public' not below the relative path of its package 'tensorflow/core'. This will be an error in the future. Since this rule was created by the macro 'cc_header_only_library', the error might have been caused by the macro implementation in /Users/name/tensorflow/tensorflow/tensorflow.bzl:1047:30
WARNING: /Users/name/tensorflow/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:exporter': No longer supported. Switch to SavedModel immediately.
WARNING: /Users/name/tensorflow/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:gc': No longer supported. Switch to SavedModel immediately.
INFO: Analysed target //tensorflow/tools/pip_package:build_pip_package (221 packages loaded).
INFO: Found 1 target...
ERROR: /private/var/tmp/_bazel_name/cb03877c162e6674f9f78b12c9c0e645/external/highwayhash/BUILD.bazel:22:1: C++ compilation of rule '@highwayhash//:arch_specific' failed (Exit 1): crosstool_wrapper_driver_is_not_gcc failed: error executing command 
  (cd /private/var/tmp/_bazel_name/cb03877c162e6674f9f78b12c9c0e645/execroot/org_tensorflow && \
  exec env - \
    LD_LIBRARY_PATH=/Users/name/lib:/usr/local/cuda/lib:/usr/local/cuda/extras/CUPTI/lib:/Developer/NVIDIA/CUDA-9.0/lib \
    PATH=/usr/bin:/Developer/NVIDIA/CUDA-9.0/bin:/Users/name/lib:/usr/local/cuda/lib:/usr/local/cuda/extras/CUPTI/lib:/Developer/NVIDIA/CUDA-9.0/lib:/Users/name/miniconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin \
    PWD=/proc/self/cwd \
    TMPDIR=/var/folders/q3/4n8988wn2cx_gz7g3d7hjhv80000gn/T/ \
  external/local_config_cuda/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -g0 -O2 -DNDEBUG -ffunction-sections -fdata-sections -g0 '-std=c++11' -g0 -MD -MF bazel-out/host/bin/external/highwayhash/_objs/arch_specific/external/highwayhash/highwayhash/arch_specific.d '-frandom-seed=bazel-out/host/bin/external/highwayhash/_objs/arch_specific/external/highwayhash/highwayhash/arch_specific.o' -iquote external/highwayhash -iquote bazel-out/host/genfiles/external/highwayhash -iquote external/bazel_tools -iquote bazel-out/host/genfiles/external/bazel_tools -isystem external/bazel_tools/tools/cpp/gcc3 -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/highwayhash/highwayhash/arch_specific.cc -o bazel-out/host/bin/external/highwayhash/_objs/arch_specific/external/highwayhash/highwayhash/arch_specific.o)
gcc: error: unrecognized command line option '-fcolor-diagnostics'
gcc: error: unrecognized command line option '-Wthread-safety'; did you mean '-fthread-jumps'?
gcc: error: unrecognized command line option '-Wself-assign'; did you mean '-Wcast-align'?
Target //tensorflow/tools/pip_package:build_pip_package failed to build
INFO: Elapsed time: 29.688s, Critical Path: 0.18s
FAILED: Build did NOT complete successfully
@xlvecle

This comment has been minimized.

Copy link

commented Jan 29, 2018

@Lesbinary Tensorflow team is no longer supports macOS-gpu build and I have not fully test my build on other platforms, so it's hard to convince them to accept the PR.

@pinxue

This comment has been minimized.

Copy link

commented Jan 30, 2018

tensorflow/core/kernels/concat_lib_gpu.impl.cu.cc
is
tensorflow/core/kernels/concat_lib_gpu_impl.cu.cc
now.

@smitshilu

This comment has been minimized.

Copy link
Owner Author

commented Jan 30, 2018

@km4342 you should use full command not just bazel 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

@webprogrammingsolutions

This comment has been minimized.

Copy link

commented Jan 31, 2018

When I run the following command:

bazel build --config=cuda --config=opt --copt=-msse4.2 --copt=-mpopcnt --copt=-maes --copt=-mcx16 --verbose_failures --action_env PATH --action_env LD_LIBRARY_PATH --action_env DYLD_LIBRARY_PATH //tensorflow/tools/pip_package:build_pip_package --action_env PYTHON_BIN_PATH=/usr/bin/python

It errors out like so:

ERROR: /Users/psmith/tensorflow/tensorflow/contrib/tensor_forest/hybrid/BUILD:61:1: Executing genrule //tensorflow/contrib/tensor_forest/hybrid:training_ops_pygenrule failed (Aborted): bash failed: error executing command 
(cd /private/var/tmp/_bazel_psmith/740be14d2df868b3b127a540687eed16/execroot/org_tensorflow && \
exec env - \
CUDA_TOOLKIT_PATH=/usr/local/cuda \
CUDNN_INSTALL_PATH=/usr/local/cuda \
GCC_HOST_COMPILER_PATH=/usr/bin/gcc \
PATH=/Developer/NVIDIA/CUDA-9.1/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \
PYTHON_BIN_PATH=/usr/bin/python \
PYTHON_LIB_PATH=/usr/local/bin/../Cellar/python3/3.6.4_2/bin/../Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages \
TF_CUDA_CLANG=0 \
TF_CUDA_COMPUTE_CAPABILITIES=6.1 \
TF_CUDA_VERSION=9.1 \
TF_CUDNN_VERSION=7 \
TF_NEED_CUDA=1 \
TF_NEED_OPENCL_SYCL=0 \
TMPDIR=/var/folders/cq/b_vr8w5s1613tvtx95l7d6880000gn/T/ \
/bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; bazel-out/host/bin/tensorflow/contrib/tensor_forest/hybrid/gen_training_ops_py_wrappers_cc , '\'''\'' 0 0 > bazel-out/darwin-py3-opt/genfiles/tensorflow/contrib/tensor_forest/hybrid/ops/gen_training_ops.py'): bash failed: error executing command 
(cd /private/var/tmp/_bazel_psmith/740be14d2df868b3b127a540687eed16/execroot/org_tensorflow && \
exec env - \
CUDA_TOOLKIT_PATH=/usr/local/cuda \
CUDNN_INSTALL_PATH=/usr/local/cuda \
GCC_HOST_COMPILER_PATH=/usr/bin/gcc \
PATH=/Developer/NVIDIA/CUDA-9.1/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \
PYTHON_BIN_PATH=/usr/bin/python \
PYTHON_LIB_PATH=/usr/local/bin/../Cellar/python3/3.6.4_2/bin/../Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages \
TF_CUDA_CLANG=0 \
TF_CUDA_COMPUTE_CAPABILITIES=6.1 \
TF_CUDA_VERSION=9.1 \
TF_CUDNN_VERSION=7 \
TF_NEED_CUDA=1 \
TF_NEED_OPENCL_SYCL=0 \
TMPDIR=/var/folders/cq/b_vr8w5s1613tvtx95l7d6880000gn/T/ \
/bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; bazel-out/host/bin/tensorflow/contrib/tensor_forest/hybrid/gen_training_ops_py_wrappers_cc , '\'''\'' 0 0 > bazel-out/darwin-py3-opt/genfiles/tensorflow/contrib/tensor_forest/hybrid/ops/gen_training_ops.py')
dyld: Library not loaded: @rpath/libcudart.9.1.dylib
Referenced from: /private/var/tmp/_bazel_psmith/740be14d2df868b3b127a540687eed16/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/contrib/tensor_forest/hybrid/gen_training_ops_py_wrappers_cc
Reason: image not found
/bin/bash: line 1: 13798 Abort trap: 6           bazel-out/host/bin/tensorflow/contrib/tensor_forest/hybrid/gen_training_ops_py_wrappers_cc , '' 0 0 > bazel-out/darwin-py3-opt/genfiles/tensorflow/contrib/tensor_forest/hybrid/ops/gen_training_ops.py
Target //tensorflow/tools/pip_package:build_pip_package failed to build
INFO: Elapsed time: 0.909s, Critical Path: 0.06s
FAILED: Build did NOT complete successfully

However, when I check my filesystem, libcudart.9.1.dylib does appear to be in the correct place.

Obviously I am a noob at this, and I'm not sure what @rpath is or why it's unable to see the correct files. Can someone point me in the right direction?

@smitshilu, any ideas?

@bossbobster, can you explain exactly how you fixed it?

@webprogrammingsolutions

This comment has been minimized.

Copy link

commented Feb 1, 2018

@smitshilu I was able to finally get tensorflow to compile and install once I created a bunch of CUDA symlinks in /usr/local/bin/. Basically I kept trying to compile, and then after each error I would create a symlink for the file causing the error.

After installing the compiled wheel package, i tried a test import

python
import tensorflow as tf

This brings up a new error:

ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): Symbol not found: _PyCObject_Type
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
  Expected in: flat namespace
 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so

Any thoughts?

@xtr33me

This comment has been minimized.

Copy link

commented Feb 2, 2018

@ur001 I am getting the same error. Were you ever able to find a resolution?

--EDIT--
I'm just posting this here incase anyone else runs into the same issue @ur001 and I have had. Through my search I came across another link found here that was similar to the above instructions but for TF1.5. https://tweakmind.com/tensorflow-1-5-macos-10-13-2/

Now when I followed the instructions there I was having a different issue and unable to fully complete it due to another issue. However I noticed that I did have the latest version of xcode 9 that they referred to and it will cause the same error I was having and I noticed that both of these installs referenced 8.x. So I went down this path and followed the instructions that were advised when receiving the clang issue. After completing this, my install went through fine.

If Latest Xcode is installed:

/usr/bin/cc --version
Apple LLVM version 9.0.0 (clang-900.0.39.2)

You will get the following error:
nvcc fatal : The version ('90000') of the host compiler ('Apple clang') is not supported

To fix, install Xcode 8.3.3 and set as default
https://download.developer.apple.com/Developer_Tools/Xcode_8.3.3/Xcode8.3.3.xip

Double Click to Install, Archive Utility will Expand (takes some time)

cd ~/Downloads
mv Xcode.app Xcode-8.3.3.app
sudo mv Xcode-8.3.3.app /Applications
sudo xcode-select -s /Applications/Xcode-8.3.3.app
sudo xcodebuild -license

-- AFTER THE WHEEL IS INSTALLED THEN SET BACK ORIGINAL XCODE INSTALL --
Switch back to Current Xcode
sudo xcode-select -s /Applications/Xcode.app

@1371030

This comment has been minimized.

Copy link

commented Feb 5, 2018

macOS:10.13.2
CUDA:9.1
cudnn:7
python:2.7.10

INFO: From Compiling tensorflow/core/kernels/scatter_nd_op_gpu.cu.cc:
external/eigen_archive/unsupported/Eigen/CXX11/../../../Eigen/src/Core/arch/CUDA/Half.h(508): error: explicit specialization of class "std::__1::numeric_limitsEigen::half" must precede its first use (
(388): here)

./tensorflow/core/lib/core/status.h(32): warning: attribute "warn_unused_result" does not apply here

1 error detected in the compilation of "/private/var/tmp/_bazel_root/f605337e84baed8e30662c78b8d6ecc6/execroot/org_tensorflow/tmp23b_3197947ae751be7b/tmpxft_00015dd2_00000000-6_scatter_nd_op_gpu.cu.cpp1.ii".
ERROR: /Users/admin/tensorflow-macOS-gpu-1.5.0-rc1/tensorflow/core/kernels/BUILD:3945:1: output 'tensorflow/core/kernels/_objs/scatter_nd_op_gpu/tensorflow/core/kernels/scatter_nd_op_gpu.cu.pic.o' was not created
ERROR: /Users/admin/tensorflow-macOS-gpu-1.5.0-rc1/tensorflow/core/kernels/BUILD:3945:1: not all outputs were created or valid
Target //tensorflow/tools/pip_package:build_pip_package failed to build
INFO: Elapsed time: 50.497s, Critical Path: 11.66s
FAILED: Build did NOT complete successfully

@smitshilu

This comment has been minimized.

Copy link
Owner Author

commented Feb 5, 2018

@webprogrammingsolutions are you importing tensorflow from same directory? You should try import outside of tensorflow dir

@1371030

This comment has been minimized.

Copy link

commented Feb 7, 2018

macOS:10.13.2
CUDA:9.1
cudnn:7
python:2.7.10
tensorflow:master

ERROR: /Users/admin/tensorflow/tensorflow/python/BUILD:1417:1: Executing genrule //tensorflow/python:sdca_ops_pygenrule failed (Aborted): bash failed: error executing command /bin/bash bazel-out/darwin-opt/genfiles/tensorflow/python/sdca_ops_pygenrule.genrule_script.sh
dyld: Library not loaded: @rpath/libcudart.9.1.dylib
Referenced from: /private/var/tmp/_bazel_root/73efb106b0ed525079e168cddc3c8e2c/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/python/gen_sdca_ops_py_wrappers_cc
Reason: image not found

@liygzting

This comment has been minimized.

Copy link

commented Feb 8, 2018

Remove all align(sizeof(T)) from following files:
tensorflow/core/kernels/depthwise_conv_op_gpu.cu.cc

tensorflow/core/kernels/split_lib_gpu.cu.cc

tensorflow/core/kernels/concat_lib_gpu.impl.cu.cc

For example, extern shared align(sizeof(T)) unsigned char smem[]; => extern shared unsigned char smem[];

example just simple #
how i can do?

thanks

@smoothdvd

This comment has been minimized.

Copy link

commented Feb 18, 2018

@ur001 same error. How to resolve it?

@ngaurav

This comment has been minimized.

Copy link

commented Feb 18, 2018

@xtr33me @ur001 @smoothdvd @1371030 Same error. Let me know if there is a solution to get past the following error:

INFO: From Compiling tensorflow/core/kernels/scatter_nd_op_gpu.cu.cc:
external/eigen_archive/unsupported/Eigen/CXX11/../../../Eigen/src/Core/arch/CUDA/Half.h(508): error: explicit specialization of class "std::__1::numeric_limitsEigen::half" must precede its first use (
(388): here)

./tensorflow/core/lib/core/status.h(32): warning: attribute "warn_unused_result" does not apply here

@uliano

This comment has been minimized.

Copy link

commented Feb 18, 2018

@ngaurav & others with "eigen problem"
I was able to build a working TF 1.5 on Anaconda python 3.6 with OSX 10.13.3 Cuda 9.1 just by falling back to the 8.1 clang found in "Command Line Tools (macOS Sierra version 10.12).pkg" downloaded from Apple

@ngaurav

This comment has been minimized.

Copy link

commented Feb 18, 2018

@uliano Thanks a lot. Switching to CommandLineToolsforXcode8.3.2.dmg worked.

@anubhavjaiswal03

This comment has been minimized.

Copy link

commented Feb 19, 2018

@smitshilu, I followed the instructions to the letter on My Mac yet i keep getting the same errors:

macOS:10.13.3
CUDA:9.1
cudnn:7
python:3.6
TF 1.4.0 (Failed to compile)
TF 1.5.0 (Failed to compile)

looks like there might be a problem with bazel,
There seems to be something trivial which i am missing. Would much appreciate your help :)
Keep getting this error:
Current Bazel version is 0.10.1, expected at least 0.5.4
ERROR: Error evaluating WORKSPACE file

Anubhavs-MacBook-Pro:tensorflow-build anubhavjaiswal$ 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
.
ERROR: /Users/anubhavjaiswal/Developer/tensorflow-build/WORKSPACE:15:1: Traceback (most recent call last):
	File "/Users/anubhavjaiswal/Developer/tensorflow-build/WORKSPACE", line 15
		closure_repositories()
	File "/private/var/tmp/_bazel_anubhavjaiswal/ac71edd2ca3b9531177a94f0fef11c2d/external/io_bazel_rules_closure/closure/repositories.bzl", line 69, in closure_repositories
		_check_bazel_version("Closure Rules", "0.4.5")
	File "/private/var/tmp/_bazel_anubhavjaiswal/ac71edd2ca3b9531177a94f0fef11c2d/external/io_bazel_rules_closure/closure/repositories.bzl", line 172, in _check_bazel_version
		fail(("%s requires Bazel >=%s but was...)))
Closure Rules requires Bazel >=0.4.5 but was 0.10.1
ERROR: Error evaluating WORKSPACE file
ERROR: /Users/anubhavjaiswal/Developer/tensorflow-build/WORKSPACE:41:1: Traceback (most recent call last):
	File "/Users/anubhavjaiswal/Developer/tensorflow-build/WORKSPACE", line 41
		tf_workspace()
	File "/Users/anubhavjaiswal/Developer/tensorflow-build/tensorflow/workspace.bzl", line 48, in tf_workspace
		check_version("0.5.4")
	File "/Users/anubhavjaiswal/Developer/tensorflow-build/tensorflow/workspace.bzl", line 38, in check_version
		fail("\nCurrent Bazel version is {}, ...))

Current Bazel version is 0.10.1, expected at least 0.5.4
ERROR: Error evaluating WORKSPACE file
ERROR: Skipping '//tensorflow/tools/pip_package:build_pip_package': error loading package 'external': Package 'external' contains errors
WARNING: Target pattern parsing failed.
ERROR: error loading package 'external': Package 'external' contains errors
INFO: Elapsed time: 1.582s
FAILED: Build did NOT complete successfully (0 packages loaded)
@anirudhmurali

This comment has been minimized.

Copy link

commented Feb 19, 2018

@ghost gcc: error: unrecognized command line option '-fobjc-link-runtime'
I see that you got this error as well, I got it during the bazel build of another tool. Did you find a fix?

@smitshilu

This comment has been minimized.

Copy link
Owner Author

commented Feb 20, 2018

@anubhavjaiswal03 I would suggest installing bazel again and try .7 or .9 version.

@MichaelScript

This comment has been minimized.

Copy link

commented Feb 26, 2018

@anubhavjaiswal03 Install bazel 0.7 (Compile from the bazel release and uninstall the homebrew version because homebrew forces you to use the latest xcode and there isn't an official .7 on tap via homebrew, if there was then you could just run sudo xcode-select --switch /Library/Developer/CommandLineTools/ to switch back to the current version of xcode)

@bahadir60

This comment has been minimized.

Copy link

commented Feb 28, 2018

@smitshilu
thanks

@ghltshubh

This comment has been minimized.

Copy link

commented Mar 3, 2018

I got tensorflow compiled successfully but getting error while generating a wheel for installation.

Fri Mar 2 23:18:42 CST 2018 : === Using tmpdir: /var/folders/5p/bhsb4zjs41lblf2nd_bft5cm0000gp/T/tmp.XXXXXXXXXX.U08YYfRs
~/tensorflow/bazel-bin/tensorflow/tools/pip_package/build_pip_package.runfiles ~/tensorflow
~/tensorflow
/var/folders/5p/bhsb4zjs41lblf2nd_bft5cm0000gp/T/tmp.XXXXXXXXXX.U08YYfRs ~/tensorflow
Fri Mar 2 23:18:48 CST 2018 : === Building wheel
Traceback (most recent call last):
  File "setup.py", line 26, in <module>
    from setuptools.command.install import install as InstallCommandBase
ModuleNotFoundError: No module named 'setuptools.command'
@orpcam

This comment has been minimized.

Copy link

commented Mar 3, 2018

I got tensorflow compiled successfully but getting no output when using it.

Python 3.6.3 (default, Jan 31 2018, 13:53:45) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.__version__
'1.5.0-rc0'
>>> session = tf.Session()

The last line won't be executed. No output, no new interpreter line... Any ideas?

Update: It was my own fault. Something went wrong with my CUDA installation.

I wrote a short blog post about my successful Tensorflow 1.6-rc1 build. https://byai.io/howto-tensorflow-1-6-on-mac-with-gpu-acceleration/

@mjuchli

This comment has been minimized.

Copy link

commented Mar 8, 2018

@anubhavjaiswal03 @MichaelScript i was unable to install bazel 0.7. For me the trick was to comment out line 69 in .../external/io_bazel_rules_closure/closure/repositories.bzl: # _check_bazel_version("Closure Rules", "0.4.5")

@mjuchli

This comment has been minimized.

Copy link

commented Mar 8, 2018

Running in new error:

env: python: No such file or directory
Target //tensorflow/tools/pip_package:build_pip_package failed to build

python is definitely within the PATH and can also be called with /usr/bin/env python.
Looks like this is related: tensorflow/tensorflow#15618
Any ideas?

@smitshilu

This comment has been minimized.

Copy link
Owner Author

commented Mar 9, 2018

Try running ./configure again and set python environment variables properly

@vihanb

This comment has been minimized.

Copy link

commented Jun 7, 2018

I'm getting error:

ERROR: Inconsistent crosstool configuration; no toolchain corresponding to 'local_darwin' found for cpu 'darwin'

however I have installed brew install gcc@7 and ln -s /usr/local/bin/gcc-7 /usr/bin/gcc so not sure why still using clang instead of GCC, perhaps another issue?

@swathishesh19

This comment has been minimized.

Copy link

commented Jun 14, 2018

@smitshilu.. thank you!
Will this fix also work for AMD GPUs? or do I have to switch to an NVIDIA GPU

@smitshilu

This comment has been minimized.

Copy link
Owner Author

commented Jun 18, 2018

@swathishesh19 it will work with NVIDIA only. For now tensorflow supports officially NVIDIA GPUs only

@dandy27

This comment has been minimized.

Copy link

commented Jul 24, 2019

@coocoorhin what path are you passing while you are running ./configuration? If you check in this line
Please specify the location where CUDA 9.0 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]:
Defult path is /usr/local/cuda so export the same path even default installation path is different

i did just as he did, instead of leaving default i changed it to Developers.......

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.