无法编译 tensorflow 所需的 bazel-android

Cannot compile bazel needed for tensorflow-android

我正在尝试探索 tensorflow android 演示。我想使用 android 工作室调整应用程序。

然而,当我简单地遵循 instructions 时,无论我做什么,我都会遇到编译错误:

尝试使用 bazel 和 NDK r12b 编译 tensorflow:

$bazel build -c opt //tensorflow/examples/android:tensorflow_demo
ERROR: /home/myUser/libs/tensorflow_android/WORKSPACE:3:1: //external:io_bazel_rules_closure: no such attribute 'urls' in 'http_archive' rule.
ERROR: /home/myUser/libs/tensorflow_android/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.
INFO: Elapsed time: 0.129s

正在尝试编译 bazel following this advice 的更新版本:

$bazel version
Build label: 0.2.3-jdk7 // This is my current version of bazel

通过 apt-get:

$sudo apt-get upgrade bazel
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
E: Unable to locate package bazel

来自源代码(尝试了 bazel-0.4.2 和 bazel-0.5.0):

$./compile.sh 
INFO: You can skip this first step by providing a path to the bazel binary as second argument:
INFO:    ./compile.sh compile /path/to/bazel
  Building Bazel from scratch
ERROR: JDK version (1.7) is lower than 1.8, please set $JAVA_HOME.

$bazel build //src:bazel
ERROR: /home/myUser/libs/bazel/bazel-0.4.2/tools/build_rules/genproto.bzl:45:16: Traceback (most recent call last):
    File "/home/myUser/libs/bazel/bazel-0.4.2/tools/build_rules/genproto.bzl", line 42
        rule(gensrcjar_impl, attrs = {"src": at..."), <2 more arguments>), "_proto_compiler": attr.label(default = Label("//third_party/p..."), <4 more arguments>), "_jar": attr.label(default = Label("@bazel_tools//t..."), <4 more arguments>), "_jdk": attr.label(default = Label("@bazel_tools//t..."), ...)}, ..."})
    File "/home/myUser/libs/bazel/bazel-0.4.2/tools/build_rules/genproto.bzl", line 45, in rule
        attr.label(allow_files = proto_filetype, sing...)
allow_files should be a boolean or a filetype object.
ERROR: /home/myUser/libs/bazel/bazel-0.4.2/src/BUILD:130:1: error loading package 'src/main/protobuf': Extension file 'tools/build_rules/genproto.bzl' has errors and referenced by '//src:embedded_tools'.
ERROR: Loading failed; build aborted.
INFO: Elapsed time: 0.251s

切换 java-versions 以查看 bazel 编译问题是否来自那里:

$sudo update-alternatives --config java
There are 4 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-8-oracle/jre/bin/java          1074      auto mode
  1            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      manual mode
* 2            /usr/lib/jvm/java-7-oracle/jre/bin/java          1072      manual mode
  3            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1069      manual mode
  4            /usr/lib/jvm/java-8-oracle/jre/bin/java          1074      manual mode

到目前为止运气不好:-/。有没有人从源代码为 android 成功编译了 tensorflow?

需要什么版本的 Tensorflow、NDK、bazel java/相互兼容?我真的需要 bazel 吗? (反正从来没有用过它)我不能像其他任何应用程序一样在 android-studio 中编译 android 演示吗?

我正在使用 Ubuntu 14.04、Cuda8.0、cudnn_v5.1、Titan X Pascal(不确定这些是否重要)

无需编译即可在 Ubuntu 上安装 Bazel。

遵循专用文档的所有步骤:Install Bazel on Ubuntu