-
Notifications
You must be signed in to change notification settings - Fork 74k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linking an Android library with TFLite GPU using CMake causes undefined symbol errors #61312
Comments
Hey @GoldFeniks, I've got the same problem when building TFLite 2.13.0 with CMake. I manage to fix it by editing Before
Then, after
|
@williamdias Thank you! Interesting, looks like some sources got lost somewhere |
@GoldFeniks Could you please let us know if the issue has been resolved for you ? |
@sushreebarsa It helped resolve the TFLite related unresolved symbols, but AHardwareBuffer symbols still cannot be found |
@GoldFeniks, as for AHardwareBuffer symbols, try adding the following flag to
|
Adding In the docs the minimal supported version is still 19 or 21 for most of the modules: https://www.tensorflow.org/lite/android/development |
@williamdias I have specified that as follows (see the build.sh)
changing it to just |
Hey @AntonMalyshev, yes. It will drop compatibility to versions below 8.0. I think @GoldFeniks, here's my
I am using NDK |
@williamdias Thank you, tensorflow does in fact build with such settings, but trying to link to such tensorflow binary with anything that uses GPU delegate results in the linking errors. |
@GoldFeniks, hum, I was able to use the binary and run models on GPU. What errors are you getting? The only downside is that I had to drop support to Android < 8.0 (API 26). |
@williamdias Interesting. Are you building static or dynamic library? cmake_minimum_required(VERSION 3.26)
project(tflite_link_issue C CXX)
set(CMAKE_CXX_STANDARD 17)
add_subdirectory(tensorflow/tensorflow/lite)
add_library(gpu SHARED gpu.hpp gpu.cpp)
target_link_libraries(gpu tensorflow-lite) And I only call these functions in TfLiteGpuDelegateOptionsV2 options = TfLiteGpuDelegateOptionsV2Default();
const auto tf_delegate = tflite::Interpreter::TfLiteDelegatePtr(TfLiteGpuDelegateV2Create(&options), TfLiteGpuDelegateV2Delete); Which gives me a bunch of no symbol errors for |
@GoldFeniks, I am building static tensorflow-lite and then another static lib on top of it. Try to check if the the symbols are present in |
Turns out find_library(android-lib android REQUIRED) and changing target_link_libraries(gpu tensorflow-lite ${android-lib}) fixes the problem. |
@williamdias Thank you for the pointers. @GoldFeniks Thanks for the PR. The issue will be closed once PR #61381 is merged. |
Hi @alankelly, it seems like the PR needs a review so I'm assigning this to you for now. Thanks! |
Issue type
Build/Install
Have you reproduced the bug with TensorFlow Nightly?
No
Source
source
TensorFlow version
2.13
Custom code
Yes
OS platform and distribution
Linux 6.3.1, EndeavourOS
Mobile device
No response
Python version
No response
Bazel version
No response
GCC/compiler version
clang version 14.0.7
CUDA/cuDNN version
No response
GPU model and memory
No response
Current behavior?
Linking an Android library with libtensorflow-lite.a using CMake with GPU delegate enabled causes undefined symbol errors
Standalone code to reproduce the issue
Please find a minimal test case here.
Relevant log output
The text was updated successfully, but these errors were encountered: