tensorflow: Error when building tensorflow from source

I am trying to build and install tensorflow from source. However when building with bazel it returns an error stating Extension file ‘tensorflow/tensorflow.bzl’ has errors.

Here are the commands that I ran and the logs are included.


mkvirtualenv tensorflow_dev
brew install bazel swig
workon tensorflow_dev
pip install six numpy wheel ipython
export TF_DIR=/Users/shashank/Documents/repositories/tensorflow
cd /Users/shashank/Documents/repositories/
git clone git@github.com:tensorflow/tensorflow.git
cd $TF_DIR && ./configure

~/Documents/repositories/tensorflow ~/Documents/repositories/tensorflow
Please specify the location of python. [Default is /Users/shashank/.virtualenvs/tensorflow_dev/bin/python]:
Do you wish to build TensorFlow with Google Cloud Platform support? [y/N]
No Google Cloud Platform support will be enabled for TensorFlow
Found possible Python library paths:
  /Users/shashank/Documents/py_config/
  /Users/shashank/.virtualenvs/tensorflow_dev/lib/python2.7/site-packages
Please input the desired Python library path to use.  Default is [/Users/shashank/Documents/py_config/]

/Users/shashank/Documents/py_config/
Do you wish to build TensorFlow with GPU support? [y/N]
No GPU support will be enabled for TensorFlow
Configuration finished

cd $TF_DIR && bazel build -c opt //tensorflow/tools/pip_package:build_pip_package
ERROR: /Users/shashank/Documents/repositories/tensorflow/tensorflow/tensorflow.bzl:568:26: Traceback (most recent call last):
        File "/Users/shashank/Documents/repositories/tensorflow/tensorflow/tensorflow.bzl", line 562
            rule(attrs = {"srcs": attr.label_list..."), <3 more arguments>)}, <2 more arguments>)
        File "/Users/shashank/Documents/repositories/tensorflow/tensorflow/tensorflow.bzl", line 568, in rule
            attr.label_list(cfg = "data", allow_files = True)
expected ConfigurationTransition or NoneType for 'cfg' while calling label_list but got string instead: data.
ERROR: com.google.devtools.build.lib.packages.BuildFileContainsErrorsException: error loading package '': Extension file 'tensorflow/tensorflow.bzl' has errors.
INFO: Elapsed time: 0.063s

Thanks for your help

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 3
  • Comments: 60 (16 by maintainers)

Commits related to this issue

Most upvoted comments

I updated my bazel version to 0.3.1

Build label: 0.3.1-homebrew
Build target: bazel-out/local-fastbuild/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Aug 4 09:58:27 2016 (1470304707)
Build timestamp: 1470304707
Build timestamp as int: 1470304707

Now when I execute this command in the root dir of tensorflow. I receive a different error.

export TF_DIR=/Users/shashank/Documents/repositories/tensorflow
cd /Users/shashank/Documents/repositories/
git clone git@github.com:tensorflow/tensorflow.git
cd $TF_DIR && ./configure

~/Documents/repositories/tensorflow ~/Documents/repositories/tensorflow
Please specify the location of python. [Default is /Users/shashank/.virtualenvs/tensorflow_dev/bin/python]:
Do you wish to build TensorFlow with Google Cloud Platform support? [y/N]
No Google Cloud Platform support will be enabled for TensorFlow
Found possible Python library paths:
  /Users/shashank/Documents/py_config/
  /Users/shashank/.virtualenvs/tensorflow_dev/lib/python2.7/site-packages
Please input the desired Python library path to use.  Default is [/Users/shashank/Documents/py_config/]

/Users/shashank/Documents/py_config/
Do you wish to build TensorFlow with GPU support? [y/N]
No GPU support will be enabled for TensorFlow
Configuration finished

cd $TF_DIR && bazel build -c opt //tensorflow/tools/pip_package:build_pip_package
..
ERROR: /Users/shashank/Documents/repositories/tensorflow/tensorflow/BUILD:69:1: //tensorflow:all_files: invalid label '@' in element 0 of attribute 'srcs' in 'filegroup' rule: invalid fully-qualified label: @.
ERROR: /Users/shashank/Documents/repositories/tensorflow/tensorflow/BUILD:84:12: Target '//tensorflow:internal' contains an error and its package is in error (this is usually caused by a missing package group in the package-level visibility declaration).
ERROR: /Users/shashank/Documents/repositories/tensorflow/tensorflow/BUILD:82:1: Target '//tensorflow:__init__.py' contains an error and its package is in error and referenced by '//tensorflow:tensorflow_py'.
ERROR: /Users/shashank/Documents/repositories/tensorflow/tensorflow/tools/pip_package/BUILD:16:1: Target '//tensorflow:tensorflow_py' contains an error and its package is in error and referenced by '//tensorflow/tools/pip_package:simple_console'.
ERROR: /Users/shashank/Documents/repositories/tensorflow/tensorflow/tools/pip_package/BUILD:23:1: Target '//tensorflow:tensorflow_py' contains an error and its package is in error and referenced by '//tensorflow/tools/pip_package:build_pip_package'.
ERROR: Analysis of target '//tensorflow/tools/pip_package:build_pip_package' failed; build aborted.
INFO: Elapsed time: 2.489s

Try to update your bazel installation. I had this problem a few minutes ago, and this seems to have solved it on my side.

`syj@syj-dl:~$mv tensorflow tensorflow.bak0917

syj@syj-dl:~$ git clone https://github.com/tensorflow/tensorflow 正克隆到 ‘tensorflow’… remote: Counting objects: 87905, done. remote: Compressing objects: 100% (685/685), done. remote: Total 87905 (delta 384), reused 0 (delta 0), pack-reused 87215 接收对象中: 100% (87905/87905), 57.97 MiB | 1.28 MiB/s, 完成. 处理 delta 中: 100% (65026/65026), 完成. 检查连接… 完成。

syj@syj-dl:~$ cd tensorflow syj@syj-dl:~/tensorflow$ git pull --recurse-submodules Already up-to-date.

syj@syj-dl:~/tensorflow$ vi tensorflow/contrib/session_bundle/BUILD syj@syj-dl:~/tensorflow$ vi tensorflow/core/BUILD syj@syj-dl:~/tensorflow$ vi tensorflow/core/kernels/BUILD

syj@syj-dl:~/tensorflow$ ./configure ~/tensorflow ~/tensorflow Please specify the location of python. [Default is /home/syj/anaconda2/bin/python]: Do you wish to build TensorFlow with Google Cloud Platform support? [y/N] y Google Cloud Platform support will be enabled for TensorFlow Found possible Python library paths: /home/syj/anaconda2/lib/python2.7/site-packages Please input the desired Python library path to use. Default is [/home/syj/anaconda2/lib/python2.7/site-packages] /home/syj/anaconda2/lib/python2.7/site-packages Do you wish to build TensorFlow with GPU support? [y/N] y GPU support will be enabled for TensorFlow Please specify which gcc should be used by nvcc 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]: 8.0 Please specify the location where CUDA 8.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 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.

INFO: Starting clean (this may take a while). Consider using --expunge_async if the clean takes more than several minutes. . INFO: All external dependencies fetched successfully. Configuration finished `

`syj@syj-dl:~/tensorflow$ bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package

Target //tensorflow/tools/pip_package:build_pip_package up-to-date: bazel-bin/tensorflow/tools/pip_package/build_pip_package INFO: Elapsed time: 789.711s, Critical Path: 749.46s

syj@syj-dl:~/tensorflow$ bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg 2016年 09月 17日 星期六 11:12:39 CST : === Using tmpdir: /tmp/tmp.DoXXfMKIU3 /tmp/tmp.DoXXfMKIU3 ~/tensorflow 2016年 09月 17日 星期六 11:12:39 CST : === Building wheel ~/tensorflow 2016年 09月 17日 星期六 11:12:51 CST : === Output wheel file is in: /tmp/tensorflow_pkg

syj@syj-dl:~/tensorflow$ pip install /tmp/tensorflow_pkg/tensorflow-0.10.0-py2-none-any.whl Processing /tmp/tensorflow_pkg/tensorflow-0.10.0-py2-none-any.whl Requirement already satisfied (use --upgrade to upgrade): numpy>=1.8.2 in /home/syj/anaconda2/lib/python2.7/site-packages (from tensorflow==0.10.0) Collecting mock>=2.0.0 (from tensorflow==0.10.0) Downloading mock-2.0.0-py2.py3-none-any.whl (56kB) 100% |████████████████████████████████| 61kB 15kB/s Collecting protobuf==3.0.0b2 (from tensorflow==0.10.0) Downloading protobuf-3.0.0b2-py2.py3-none-any.whl (326kB) 100% |████████████████████████████████| 327kB 10kB/s Requirement already satisfied (use --upgrade to upgrade): wheel in /home/syj/anaconda2/lib/python2.7/site-packages (from tensorflow==0.10.0) Requirement already satisfied (use --upgrade to upgrade): six>=1.10.0 in /home/syj/anaconda2/lib/python2.7/site-packages (from tensorflow==0.10.0) Requirement already satisfied (use --upgrade to upgrade): funcsigs>=1; python_version < “3.3” in /home/syj/anaconda2/lib/python2.7/site-packages (from mock>=2.0.0->tensorflow==0.10.0) Collecting pbr>=0.11 (from mock>=2.0.0->tensorflow==0.10.0) Downloading pbr-1.10.0-py2.py3-none-any.whl (96kB) 100% |████████████████████████████████| 102kB 12kB/s Requirement already satisfied (use --upgrade to upgrade): setuptools in /home/syj/anaconda2/lib/python2.7/site-packages/setuptools-23.0.0-py2.7.egg (from protobuf==3.0.0b2->tensorflow==0.10.0) Installing collected packages: pbr, mock, protobuf, tensorflow Found existing installation: protobuf 3.0.0 Uninstalling protobuf-3.0.0: Successfully uninstalled protobuf-3.0.0 Successfully installed mock-2.0.0 pbr-1.10.0 protobuf-3.0.0b2 tensorflow-0.10.0

syj@syj-dl:~/tensorflow/tensorflow/models/image/mnist$ python convolutional.py I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcublas.so.8.0 locally I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcudnn.so.5 locally I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcufft.so.8.0 locally I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcuda.so.1 locally I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcurand.so.8.0 locally Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes. Successfully downloaded train-labels-idx1-ubyte.gz 28881 bytes. Successfully downloaded t10k-images-idx3-ubyte.gz 1648877 bytes. Successfully downloaded t10k-labels-idx1-ubyte.gz 4542 bytes. Extracting data/train-images-idx3-ubyte.gz Extracting data/train-labels-idx1-ubyte.gz Extracting data/t10k-images-idx3-ubyte.gz Extracting data/t10k-labels-idx1-ubyte.gz I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:925] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero I tensorflow/core/common_runtime/gpu/gpu_device.cc:951] Found device 0 with properties: name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate (GHz) 1.8225 pciBusID 0000:01:00.0 Total memory: 7.92GiB Free memory: 7.53GiB I tensorflow/core/common_runtime/gpu/gpu_device.cc:972] DMA: 0 I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] 0: Y I tensorflow/core/common_runtime/gpu/gpu_device.cc:1041] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:01:00.0) Initialized! Step 0 (epoch 0.00), 7.2 ms Minibatch loss: 12.054, learning rate: 0.010000 Minibatch error: 90.6% Validation error: 84.6%

… Step 8500 (epoch 9.89), 5.1 ms Minibatch loss: 1.619, learning rate: 0.006302 Minibatch error: 1.6% Validation error: 0.8% Test error: 0.8%

`

Thank you all @andrewharp, @gustavla, @aselle, @shkr , with your kind help after over 10 days attempt the configuration passed. 😃

@szsongyj Perhaps try one of the methods suggested here: http://stackoverflow.com/questions/14318234/how-to-ignore-error-on-git-pull-about-my-local-changes-would-be-overwritten-by-m

Alternatively follow the xkcd method and start over, this time with --recurse-submodules 😃

ERROR: /home/syj/tensorflow/tensorflow/workspace.bzl:85:3: no such package ‘@six_archive//’: Error downloading from https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55 to /home/syj/.cache/bazel/_bazel_syj/47b860f752d3ee48e8d208f528a56395/external/six_archive: Error downloading https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55 to /home/syj/.cache/bazel/_bazel_syj/47b860f752d3ee48e8d208f528a56395/external/six_archive/six-1.10.0.tar.gz: Connection timed out and referenced by ‘//external:six’. ERROR: Evaluation of query “deps((//… union @bazel_tools//tools/jdk:toolchain))” failed: errors were encountered while computing transitive closure.

@shkr The internal fix https://github.com/tensorflow/tensorflow/commit/f66b491a06627510c1cf751fc11db2caf5aa1f25 was pushed today in https://github.com/tensorflow/tensorflow/pull/4360, so if you sync now I assume the issue will go away. I had just forgotten it was part of the push when I asked you about the copy-paste.