tensorflow: tensorflow macOS build failed

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): N/A

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): macOS 10.13

  • TensorFlow installed from (source or binary): build from source branch r1.6

  • TensorFlow version (use command below): 1.6

  • Python version: 3.6

  • Bazel version (if compiling from source): 0.11.0-homebrew

  • GCC/Compiler version (if compiling from source): Apple LLVM version 9.0.0 (clang-900.0.39.2)

  • CUDA/cuDNN version: 9.1/7.0.5

  • GPU model and memory: Titan X Pascal

  • Exact command to reproduce: bazel build --config=opt --config=cuda --config=mkl //tensorflow/tools/pip_package:build_pip_package

Describe the problem

Trying to build from source, but failed with the error below

Source code / logs

INFO: From Compiling tensorflow/contrib/rnn/kernels/gru_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)

1 error detected in the compilation of "/var/folders/4z/2frllwtj73b9vg25g4m9sxsc0000gn/T//tmpxft_00002f28_00000000-6_gru_ops_gpu.cu.cpp1.ii".
ERROR: /Users/odin/local/tensorflow/tensorflow/contrib/rnn/BUILD:240:1: output 'tensorflow/contrib/rnn/_objs/python/ops/_gru_ops_gpu/tensorflow/contrib/rnn/kernels/gru_ops_gpu.cu.pic.o' was not created
ERROR: /Users/odin/local/tensorflow/tensorflow/contrib/rnn/BUILD:240:1: not all outputs were created or valid

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 23 (6 by maintainers)

Most upvoted comments

The workspace.bzl in tensorflow directory should be modified as

`tf_http_archive( name = “com_google_protobuf”, urls = [ “https://mirror.bazel.build/github.com/google/protobuf/archive/396336eb961b75f03b25824fe86cf6490fb75e3a.tar.gz”, “https://github.com/google/protobuf/archive/396336eb961b75f03b25824fe86cf6490fb75e3a.tar.gz”, ], sha256 = “846d907acf472ae233ec0882ef3a2d24edbbe834b80c305e867ac65a1f2c59e3”, strip_prefix = “protobuf-396336eb961b75f03b25824fe86cf6490fb75e3a”, )

tf_http_archive( name = “com_google_protobuf_cc”, urls = [ “https://mirror.bazel.build/github.com/google/protobuf/archive/396336eb961b75f03b25824fe86cf6490fb75e3a.tar.gz”, “https://github.com/google/protobuf/archive/396336eb961b75f03b25824fe86cf6490fb75e3a.tar.gz”, ], sha256 = “846d907acf472ae233ec0882ef3a2d24edbbe834b80c305e867ac65a1f2c59e3”, strip_prefix = “protobuf-396336eb961b75f03b25824fe86cf6490fb75e3a”, )`

and the depthwise_conv_op_gpu.cu.cc, split_lib_gpu.cu.cc,concat_lib_gpu_impl.cu.cc in the core/kernels,you need change all the lines like:

extern __shared__ __align__(sizeof(T)) unsigned char smem[];

into

extern __shared__ unsigned char smem[];

by delete __align__(sizeof(T)) . Then everything will be OK.

I have successfully build tensorflow-gpu for python 3.6 with compute capability 6.1 CUDNN 7 Cuda 9.1, you can download from following links (CC stands for compute capability):

tensorflow 1.6 gpu mac version without XLA and CC: 6.1

tensorflow 1.6 gpu mac version with XLA and CC: 3.5 5.2

tensorflow 1.6 gpu mac version with XLA and CC: 6.1

Maybe in the Mac system when you call

sess = tf.Session()

You will get CUDA_ERROR_OUT_OF_MEMORY , but the code will still keep running. Just ignore it.

After you install the latest Keras from the GitHub, you can switch to example directory and run:

python mnist_cnn.py /Users/zhipingxu/anaconda3/lib/python3.6/site-packages/h5py/init.py:34: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters Using TensorFlow backend. x_train shape: (60000, 28, 28, 1) 60000 train samples 10000 test samples Train on 60000 samples, validate on 10000 samples Epoch 1/12 2018-03-07 23:10:16.691546: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:859] OS X does not support NUMA - returning NUMA node zero 2018-03-07 23:10:16.691676: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1212] Found device 0 with properties: name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate(GHz): 1.8225 pciBusID: 0000:01:00.0 totalMemory: 8.00GiB freeMemory: 6.39GiB 2018-03-07 23:10:16.800598: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:859] OS X does not support NUMA - returning NUMA node zero 2018-03-07 23:10:16.800690: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1212] Found device 1 with properties: name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate(GHz): 1.7845 pciBusID: 0000:02:00.0 totalMemory: 8.00GiB freeMemory: 7.85GiB 2018-03-07 23:10:16.800747: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1227] Device peer to peer matrix 2018-03-07 23:10:16.800776: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1233] DMA: 0 1 2018-03-07 23:10:16.800781: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1243] 0: Y N 2018-03-07 23:10:16.800785: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1243] 1: N Y 2018-03-07 23:10:16.800791: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1312] Adding visible gpu devices: 0, 1 2018-03-07 23:10:17.289678: I tensorflow/core/common_runtime/gpu/gpu_device.cc:993] Creating TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6169 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080, pci bus id: 0000:01:00.0, compute capability: 6.1) 2018-03-07 23:10:17.380943: I tensorflow/core/common_runtime/gpu/gpu_device.cc:993] Creating TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:1 with 7588 MB memory) -> physical GPU (device: 1, name: GeForce GTX 1080, pci bus id: 0000:02:00.0, compute capability: 6.1) 2018-03-07 23:10:17.381334: E tensorflow/stream_executor/cuda/cuda_driver.cc:936] failed to allocate 7.41G (7956931840 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY 2018-03-07 23:10:17.381483: E tensorflow/stream_executor/cuda/cuda_driver.cc:936] failed to allocate 6.67G (7161238016 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY 60000/60000 [==============================] - 7s 125us/step - loss: 0.2544 - acc: 0.9206 - val_loss: 0.0579 - val_acc: 0.9815 Epoch 2/12 60000/60000 [==============================] - 5s 78us/step - loss: 0.0881 - acc: 0.9740 - val_loss: 0.0408 - val_acc: 0.9866 Epoch 3/12 60000/60000 [==============================] - 5s 77us/step - loss: 0.0675 - acc: 0.9799 - val_loss: 0.0369 - val_acc: 0.9883 Epoch 4/12 60000/60000 [==============================] - 5s 78us/step - loss: 0.0543 - acc: 0.9835 - val_loss: 0.0299 - val_acc: 0.9894 Epoch 5/12 60000/60000 [==============================] - 5s 78us/step - loss: 0.0478 - acc: 0.9857 - val_loss: 0.0310 - val_acc: 0.9888 Epoch 6/12 60000/60000 [==============================] - 5s 78us/step - loss: 0.0423 - acc: 0.9871 - val_loss: 0.0269 - val_acc: 0.9907 Epoch 7/12 60000/60000 [==============================] - 5s 78us/step - loss: 0.0370 - acc: 0.9885 - val_loss: 0.0294 - val_acc: 0.9907 Epoch 8/12 60000/60000 [==============================] - 5s 78us/step - loss: 0.0347 - acc: 0.9892 - val_loss: 0.0265 - val_acc: 0.9920 Epoch 9/12 60000/60000 [==============================] - 5s 78us/step - loss: 0.0309 - acc: 0.9907 - val_loss: 0.0299 - val_acc: 0.9912 Epoch 10/12 60000/60000 [==============================] - 5s 77us/step - loss: 0.0295 - acc: 0.9906 - val_loss: 0.0273 - val_acc: 0.9921 Epoch 11/12 60000/60000 [==============================] - 5s 77us/step - loss: 0.0284 - acc: 0.9915 - val_loss: 0.0282 - val_acc: 0.9910 Epoch 12/12 60000/60000 [==============================] - 5s 78us/step - loss: 0.0278 - acc: 0.9915 - val_loss: 0.0258 - val_acc: 0.9918 Test loss: 0.025763810957170064 Test accuracy: 0.9918

Everything looks fine!