tensorflow: Compilation fails on protobuf_archive

System information

  • OS Platform and Distribution: Linux Ubuntu 18.04
  • TensorFlow installed from: source
  • TensorFlow version: 1.12
  • Python version: 3.6.7
  • Installed using virtualenv? pip? conda?: virtualenv
  • Bazel version (if compiling from source): 0.22.0
  • GCC/Compiler version (if compiling from source): 7.3.0
  • CUDA/cuDNN version: N/A, compiling for CPU
  • GPU model and memory: N/A, compiling for CPU

Describe the problem

Bazel build fails on protobuf_archive with the following error:

builtin variable ‘REPOSITORY_NAME’ is referenced before assignment.

I’m building for CPU only because I’m running on an old Xeon that does not have AVX. I’ve checked out the v1.12 tag and answered n to every question on ./configure.

Provide the exact sequence of commands / steps that you executed before running into the problem

$ git checkout v1.12.0
$ ./configure
WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files
:
/home/vitor/tensorflow/tools/bazel.rc
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
INFO: Invocation ID: 942c71ae-f211-47ba-bbfe-b9a1b929dd5a
You have bazel 0.22.0 installed.
Please specify the location of python. [Default is /usr/bin/python]:


Found possible Python library paths:
  /usr/lib/python3/dist-packages
  /usr/local/lib/python3.6/dist-packages
Please input the desired Python library path to use.  Default is [/usr/lib/python3/dist-packages]

Do you wish to build TensorFlow with Apache Ignite support? [Y/n]: n
No Apache Ignite 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 OpenCL SYCL support? [y/N]: n
No OpenCL SYCL support will be enabled for TensorFlow.

Do you wish to build TensorFlow with ROCm support? [y/N]: n
No ROCm support will be enabled for TensorFlow.

Do you wish to build TensorFlow with CUDA support? [y/N]: n
No CUDA support will be enabled for TensorFlow.

Do you wish to download a fresh release of clang? (Experimental) [y/N]: n
Clang will not be downloaded.

Do you wish to build TensorFlow with MPI support? [y/N]: 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]:


Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: n
Not configuring the WORKSPACE for Android builds.

Preconfigured Bazel build configs. You can use any of the below by adding "--config=<>" to your build command. See tools/bazel.rc for more deta
ils.
        --config=mkl            # Build with MKL support.
        --config=monolithic     # Config for mostly static monolithic build.
        --config=gdr            # Build with GDR support.
        --config=verbs          # Build with libverbs support.
        --config=ngraph         # Build with Intel nGraph support.
Configuration finished
$ bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package

WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files
:
/home/vitor/tensorflow/tools/bazel.rc
Starting local Bazel server and connecting to it...
INFO: Invocation ID: f013afad-a38e-4b6d-a3bd-f2f48351c346
ERROR: error loading package '': Encountered error while reading extension file 'closure/defs.bzl': no such package '@io_bazel_rules_closure//c
losure': The native http_archive rule is deprecated. load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") for a drop-in replace
ment.
Use --incompatible_remove_native_http_archive=false to temporarily continue using the native rule.
ERROR: error loading package '': Encountered error while reading extension file 'closure/defs.bzl': no such package '@io_bazel_rules_closure//c
losure': The native http_archive rule is deprecated. load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") for a drop-in replace
ment.
Use --incompatible_remove_native_http_archive=false to temporarily continue using the native rule.
INFO: Elapsed time: 2.204s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
    Fetching @io_bazel_rules_closure; fetching
$ bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package --incompatible_remove_native_http_archive=false
WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files
:
/home/vitor/tensorflow/tools/bazel.rc
INFO: Invocation ID: 86bed03e-2ee9-40f3-a646-9637f9c77ac2
ERROR: /home/vitor/.cache/bazel/_bazel_vitor/24c362ffbb1041b0533e8d298828b5ea/external/protobuf_archive/BUILD:591:1: Traceback (most recent cal
l last):
        File "/home/vitor/.cache/bazel/_bazel_vitor/24c362ffbb1041b0533e8d298828b5ea/external/protobuf_archive/BUILD", line 591
                internal_gen_well_known_protos_java(srcs = WELL_KNOWN_PROTOS)
        File "/home/vitor/.cache/bazel/_bazel_vitor/24c362ffbb1041b0533e8d298828b5ea/external/protobuf_archive/protobuf.bzl", line 269, in inte
rnal_gen_well_known_protos_java
                Label(("%s//protobuf_java" % REPOSITOR...))
        File "/home/vitor/.cache/bazel/_bazel_vitor/24c362ffbb1041b0533e8d298828b5ea/external/protobuf_archive/protobuf.bzl", line 269, in Labe
l
                REPOSITORY_NAME
builtin variable 'REPOSITORY_NAME' is referenced before assignment.
ERROR: /home/vitor/.cache/bazel/_bazel_vitor/24c362ffbb1041b0533e8d298828b5ea/external/protobuf_archive/BUILD:373:1: Target '@protobuf_archive/
/:android' contains an error and its package is in error and referenced by '@protobuf_archive//:protoc'
ERROR: /home/vitor/.cache/bazel/_bazel_vitor/24c362ffbb1041b0533e8d298828b5ea/external/protobuf_archive/BUILD:373:1: Target '@protobuf_archive/
/:msvc' contains an error and its package is in error and referenced by '@protobuf_archive//:protoc'
ERROR: /home/vitor/tensorflow/tensorflow/contrib/boosted_trees/proto/BUILD:25:1: Target '@protobuf_archive//:protobuf_python_genproto' contains
 an error and its package is in error and referenced by '//tensorflow/contrib/boosted_trees/proto:split_info_proto_py_genproto'
ERROR: /home/vitor/tensorflow/tensorflow/contrib/boosted_trees/proto/BUILD:25:1: Target '@protobuf_archive//:protoc' contains an error and its
package is in error and referenced by '//tensorflow/contrib/boosted_trees/proto:split_info_proto_py_genproto'
ERROR: /home/vitor/tensorflow/tensorflow/contrib/boosted_trees/proto/BUILD:25:1: Target '@protobuf_archive//:protobuf_python' contains an error
 and its package is in error and referenced by '//tensorflow/contrib/boosted_trees/proto:split_info_proto_py'
ERROR: Analysis of target '//tensorflow/tools/pip_package:build_pip_package' failed; build aborted: Analysis failed
INFO: Elapsed time: 8.874s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (166 packages loaded, 2541 targets configured)
    currently loading: tensorflow/core/kernels ... (3 packages)
    Fetching @org_sqlite; fetching
    Fetching @swig; fetching
    Fetching @absl_py; fetching
    Fetching @com_google_absl; fetching
    Fetching @nsync; fetching

Any other info / logs

I’ve looked around for this error and I haven’t found anything. Closest I got is https://github.com/tensorflow/tensorflow/issues/17709 which seems completely unrelated. I’m following the documentation ipsis litteris and I know nothing of the internals of TensorFlow so the error doesn’t give me any clue as to what I can do.

About this issue

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

Most upvoted comments

@jvishnuvardhan Sure, here’s what I did:

# remove bazel 0.22
rm -rf ~/.bazel

# download bazel 0.15
wget https://github.com/bazelbuild/bazel/releases/download/0.15.0/bazel-0.15.0-installer-linux-x86_64.sh

# install bazel 0.15
chmod u+x bazel-0.15.0-installer-linux-x86_64.sh
./bazel-0.15.0-installer-linux-x86_64.sh --user

# checkout release 1.12.0
cd tensorflow
git checkout v1.12.0

# clean up
git clean -xdf
bazel shutdown
bazel clean

# compile
./configure
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package --incompatible_remove_native_http_archive=false --verbose_failures --
cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"
./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

Some of these flags or directory paths need to be adjusted depending on each person’s configuration.

Thanks for verifying @vdemario In latest versions, we are adding a maximum bazel version check to avoid such issues. Sorry for the inconvenience, and thank you very much for your patience.

@vdemario Thanks for taking time to post all the steps. I am sure community will get benefited. Thanks again!