hamlatzis
hamlatzis

Reputation: 81

Problem building TensorFlow Lite for Android

I get a lot of errors when I'm trying to build TensorFlow Lite for Android. I'm following the guidelines from https://www.tensorflow.org/lite/guide/ops_select using the code:

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

even tried with:

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

but I get errors like:

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

Also tried to follow https://becominghuman.ai/how-to-build-tensorflow-as-a-static-library-for-android-5c762dbdd5d4 to create a static library, but then I get different kind of errors in other files

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

My build system is Ubuntu and I am in the r1.14 branch

Has anyone managed to build TensorFlow Lite for Android that could give me some advise?

Upvotes: 0

Views: 440

Answers (1)

Pavel Konovalov
Pavel Konovalov

Reputation: 414

I don't know about the first bunch of errors but I got the second one then tried to compile TFLite with an old NDK version. Try to use Android NDK Revision 18b and don't forget to rerun configure script.

Upvotes: 1

Related Questions