tensorflow - 构建适用于 Android 的 TensorFlow Lite 时出现问题

标签 tensorflow machine-learning tensorflow-lite

当我尝试构建适用于 Android 的 TensorFlow Lite 时,出现了很多错误。我遵循 https://www.tensorflow.org/lite/guide/ops_select 的指导方针使用代码:

bazel build --cxxopt='--std=c++11' -c opt             \
  --config=android_arm --config=monolithic          \
  //tensorflow/lite/java:tensorflow-lite-with-select-tf-ops

甚至尝试过:

bazel build --cxxopt='--std=c++11' -c opt             \
  --config=android_arm64 --config=monolithic          \
  //tensorflow/lite/java:tensorflow-lite-with-select-tf-ops

但我收到如下错误:

Execution platform: @bazel_tools//platforms:host_platform
external/com_google_absl/absl/synchronization/mutex.cc:1103:1: error: 'xray_log_args' attribute is invalid for the implicit this argument
ABSL_XRAY_LOG_ARGS(1) void Mutex::Block(PerThreadSynch *s) {
^                  ~
external/com_google_absl/absl/base/attributes.h:514:38: note: expanded from macro 'ABSL_XRAY_LOG_ARGS'
    [[clang::xray_always_instrument, clang::xray_log_args(N)]]
                                     ^                    ~
external/com_google_absl/absl/synchronization/mutex.cc:1450:1: error: 'xray_log_args' attribute is invalid for the implicit this argument
ABSL_XRAY_LOG_ARGS(1) void Mutex::Lock() {
^                  ~
external/com_google_absl/absl/base/attributes.h:514:38: note: expanded from macro 'ABSL_XRAY_LOG_ARGS'
    [[clang::xray_always_instrument, clang::xray_log_args(N)]]
                                     ^                    ~
external/com_google_absl/absl/synchronization/mutex.cc:1468:1: error: 'xray_log_args' attribute is invalid for the implicit this argument
ABSL_XRAY_LOG_ARGS(1) void Mutex::ReaderLock() {
^                  ~
external/com_google_absl/absl/base/attributes.h:514:38: note: expanded from macro 'ABSL_XRAY_LOG_ARGS'
    [[clang::xray_always_instrument, clang::xray_log_args(N)]]
                                     ^                    ~
external/com_google_absl/absl/synchronization/mutex.cc:1581:1: error: 'xray_log_args' attribute is invalid for the implicit this argument
ABSL_XRAY_LOG_ARGS(1) bool Mutex::TryLock() {
^                  ~
external/com_google_absl/absl/base/attributes.h:514:38: note: expanded from macro 'ABSL_XRAY_LOG_ARGS'
    [[clang::xray_always_instrument, clang::xray_log_args(N)]]
                                     ^                    ~
external/com_google_absl/absl/synchronization/mutex.cc:1610:1: error: 'xray_log_args' attribute is invalid for the implicit this argument
ABSL_XRAY_LOG_ARGS(1) bool Mutex::ReaderTryLock() {
^                  ~
external/com_google_absl/absl/base/attributes.h:514:38: note: expanded from macro 'ABSL_XRAY_LOG_ARGS'
    [[clang::xray_always_instrument, clang::xray_log_args(N)]]
                                     ^                    ~
external/com_google_absl/absl/synchronization/mutex.cc:1656:1: error: 'xray_log_args' attribute is invalid for the implicit this argument
ABSL_XRAY_LOG_ARGS(1) void Mutex::Unlock() {
^                  ~
external/com_google_absl/absl/base/attributes.h:514:38: note: expanded from macro 'ABSL_XRAY_LOG_ARGS'
    [[clang::xray_always_instrument, clang::xray_log_args(N)]]
                                     ^                    ~
external/com_google_absl/absl/synchronization/mutex.cc:1708:1: error: 'xray_log_args' attribute is invalid for the implicit this argument
ABSL_XRAY_LOG_ARGS(1) void Mutex::ReaderUnlock() {
^                  ~
external/com_google_absl/absl/base/attributes.h:514:38: note: expanded from macro 'ABSL_XRAY_LOG_ARGS'
    [[clang::xray_always_instrument, clang::xray_log_args(N)]]
                                     ^                    ~
7 errors generated.
Target //tensorflow/lite/java:tensorflow-lite-with-select-tf-ops failed to build
INFO: Elapsed time: 555.749s, Critical Path: 174.46s
INFO: 490 processes: 485 local, 5 worker.
FAILED: Build did NOT complete successfully

还尝试关注https://becominghuman.ai/how-to-build-tensorflow-as-a-static-library-for-android-5c762dbdd5d4创建静态库,但随后我在其他文件中遇到不同类型的错误

 error: 'to_string' is not a member of 'std'

我的构建系统是 Ubuntu,我在 r1.14 分支

有没有人成功构建了适用于 Android 的 TensorFlow Lite,可以给我一些建议?

最佳答案

我不知道第一组错误,但我得到了第二个错误,然后尝试使用旧的 NDK 版本编译 TFLite。尝试使用 Android NDK 修订版 18b,并且不要忘记重新运行配置脚本。

关于tensorflow - 构建适用于 Android 的 TensorFlow Lite 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56187449/

相关文章:

tensorflow - 如何在浏览器上使用 TFJS 运行 TFLite 模型(AutoML Vision Edge)

python - 使用 Python 3 卡住 TensorFlow 中 Inception V3 的部分层

python - 如何从头开始训练 gpt 2?

python - 多标签分类: keras custom metrics

python - 如何在keras中进行多类图像分类?

machine-learning - 用新数据重新训练CNN

android - Tensorflow 的应用程序相机图像模糊

python - Tensorflow Lite,图像大小零误差

c++ - 错误 : Invalid options syntax: -//tensorflow:libtensorflow_cc. 所以

tensorflow - 使用tf.tile复制张量N次