bazel / tensorflow安装中的错误'external:io_bazel_rules_closure:'http_archive'规则中没有这样的属性'urls'。

时间:2017-03-23 13:13:28

标签: tensorflow ubuntu-16.04 bazel

大家好我正试图在ubuntu pc(cuda 8)上使用本指南“guide 1”和guide 2来安装具有GPU兼容性的张量流。我被困在安装tensorflow, 当我使用./configure时,我收到此错误

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.

我是ubuntu的新手,在阅读了很多内容之后我才明白,这个错误与“version of bazel”有关(对于0.3.1以上的版本,它并不适用)。 当我使用命令

$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

当我使用

$ 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.

和 使用$ sudo apt-get upgrade bazel升级了它。最后我试了

$ 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

这表明我的版本是0.3.0。我甚至尝试再次编译tensorflow,这给了我同样的错误。

1 个答案:

答案 0 :(得分:0)

您的系统上看起来有两个版本的Bazel(0.3.0和0.4.5)。您可以通过运行which bazel来查看当前二进制文件的内容。您可以通过运行以下命令找到系统中的所有bazel:

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

假设返回的内容如下:

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

你可以弄明白哪个是"对"一个(0.4.5)运行/usr/bin/bazel version等每个bazel slocate找到。

一旦找到合适的bazel,您希望它是默认的,因此您必须首先确保Linux在该目录中搜索Bazel。如果正确的bazel是/ usr / local / bin / bazel,你就可以运行:

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

然后你应该可以打电话给" bazel"通常,您的系统会找到"对"一个(你也可以删除你找到的任何旧的)。

或者,您可以使用the installer安装Bazel,它将告诉您安装了哪个目录。