我正在嘗試探索tensorflow android演示。我想使用android studio修改應用程序。無法編譯tensorflow所需的bazel-android
然而,當我只需按照instructions我得到的編譯錯誤,無論我做什麼:
嘗試使用巴澤爾和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較新版本以下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
從源(試過巴澤勒-0.4.2和巴澤爾-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
切換aroung Java的版本看巴澤爾是否編制問題來自那裏:
$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,泰坦X帕斯卡(不知道這些事情無關緊要)
嗨,你可以嘗試用一個較新版本的巴澤爾? 0.2.3是一個非常舊的版本。最新版本是0.5.1 – Steren
0.2.3是我的系統上當前安裝的版本。我試圖編譯的版本(從github獲取)是0.5.0和0.5.1 – mcExchange
爲什麼你需要編譯它?在Ubuntu上安裝Bazel可以在不編譯的情況下完成。請遵循以下專用文檔:[在Ubuntu上安裝Bazel](https://bazel.build/versions/master/docs/install-ubuntu.html) – Steren