Search code examples
tensorflowubuntu-16.04bazel

error in bazel/ tensorflow installation 'external:io_bazel_rules_closure: no such attribute 'urls' in 'http_archive' rule.'


Hi all I am trying to install tensor flow with GPU compatibility using this guide "guide 1" and guide 2 on ubuntu pc (cuda 8). I am stuck at installing tensorflow, when I use ./configure, I getting this error

ERROR: /home/krishna/tensorflow/WORKSPACE:3:1: //external:io_bazel_rules_closure: no such attribute 'urls' in 'http_archive' rule.
ERROR: /home/krishna/tensorflow/WORKSPACE:3:1: //external:io_bazel_rules_closure: missing value for mandatory attribute 'url' in 'http_archive' rule.
ERROR: com.google.devtools.build.lib.packages.BuildFileContainsErrorsException: error loading package '': Encountered error while reading extension file 'closure/defs.bzl': no such package '@io_bazel_rules_closure//closure': error loading package 'external': Could not load //external package.

I am new to ubuntu, after reading a lot I understood that, the error has something to do with "version of bazel" (for version above 0.3.1 it does not apper). When I use the command

$bazel version

Build label: 0.3.0
Build target: bazel-out/local-fastbuild/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri Jun 10 11:38:23 2016 (1465558703)
Build timestamp: 1465558703
Build timestamp as int: 1465558703

when i use

$ sudo apt-get install bazel
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    bazel is already the newest version (0.4.5).
    0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

and upgraded it using $ sudo apt-get upgrade bazel. Finally I tried

$ bazel version
Build label: 0.3.0
Build target: bazel-out/local-fastbuild/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri Jun 10 11:38:23 2016 (1465558703)
Build timestamp: 1465558703
Build timestamp as int: 1465558703

which shows me that I am at version 0.3.0. I even tried compiling tensorflow again,which gave me the same above error.


Solution

  • It looks like you have two versions of Bazel on your system (0.3.0 and 0.4.5). You can see what the current binary is by running which bazel. You can find all of the bazels on your system by running:

    $ updatedb  # This will take a while.
    $ slocate bazel
    

    Assuming this returns something like:

    /etc/bazel/bin/bazel
    /usr/bin/bazel
    

    you can figure out which bazel is the "right" one (0.4.5) by running /usr/bin/bazel version etc. for each bazel slocate finds.

    Once you find the right bazel, you want that to be the default, so you have to make sure Linux searches for Bazel in that directory first. If the right bazel is /usr/local/bin/bazel, you'd run:

    $ export PATH="/usr/local/bin:$PATH"
    

    Then you should be able to call "bazel" normally and your system will find the "right" one (you can also delete any old ones you find).

    Alternatively, you can install Bazel using the installer which will tell you what directory it got installed in.