编译tensorflow错误:Encountered error while reading extension file 'closure/defs.bzl': no such package '

编译tenwsorflow的时候出现问题:

[@localhost tensorflow]$ bazel test -c opt – //tensorflow/… -//tensorflow/compiler/… -//tensorflow/contrib/lite/…
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/xiaojin/workzone/coding/github_com/tensorflow/tools/bazel.rc
INFO: Invocation ID: 5872159f-3244-49b2-93bb-ac1e44a00e96
ERROR: error loading package ‘’: Encountered error while reading extension file ‘closure/defs.bzl’: no such package ‘@io_bazel_rules_closure//closure’: The native http_archive rule is deprecated. load("@bazel_tools//tools/build_defs/repo:http.bzl", “http_archive”) for a drop-in replacement.
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//closure’: The native http_archive rule is deprecated. load("@bazel_tools//tools/build_defs/repo:http.bzl", “http_archive”) for a drop-in replacement.
Use --incompatible_remove_native_http_archive=false to temporarily continue using the native rule.
INFO: Elapsed time: 0.029s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)

找到的解决办法:https://github.com/tensorflow/tensorflow/issues/24385
问题在于bazel版本太新,tensorflow团队用0.19.1(或更老)的版本编译的tensorflow,新版的bazel将有些功能弃用了,所以编译出错。将bazel降级到老版本就好了。

CentOS下降级bazel

之前用官方方式用yum安装了bazel,发现不能用yum downgrade 直接降级,索性卸载了。后发现github上有发布的历史版本:https://github.com/bazelbuild/bazel/releases
下载了bazel的0.18.1版本的:点击直接下载https://github.com/bazelbuild/bazel/releases/download/0.18.1/bazel-0.18.1-linux-x86_64
这是可运行程序,无需安装。

sudo chmod +x bazel-0.18.1-linux-x86_64
sudo cp bazel-0.18.1-linux-x86_64 /usr/local/bin/bazel

现在可以直接在命令行运行bazel了(如果显示找不到bazel,重开一个终端试试~)

你可能感兴趣的:(Linux,错题本,bazel,tensorflow,centos安装bazel)