asus4 / tf-lite-unity-sample

TensorFlow Lite Samples on Unity
865 stars 252 forks source link

Build for Android ARMv7 #11

Closed marimomo00 closed 2 years ago

marimomo00 commented 4 years ago

Thanks for the sample project. It helps me a lot.

I'm new to building App on Unity. I'm really need help from you. I'm trying to build the sample of Posenet for Android. I can build the Android App with ARM64, it works very well on my mobile. However, it doesn't work on my another android phone. So I tried to build with ARMv7 support. It built successfully but it runs with error. The error is,

i>AndroidPlayer(ADB@127.0.0.1:34999)</i DllNotFoundException: Unable to load DLL 'libtensorflowlite_gpu_delegate': The specified module could not be found. at TensorFlowLite.GpuDelegate.TfLiteGpuDelegateOptionsV2Default () [0x00000] in <00000000000000000000000000000000>:0 at TensorFlowLite.GpuDelegate..ctor () [0x00000] in <00000000000000000000000000000000>:0 at TensorFlowLite.BaseImagePredictor1[T].CreateGpuDelegate () [0x00000] in <00000000000000000000000000000000>:0 at TensorFlowLite.BaseImagePredictor1[T]..ctor (System.String modelPath, System.Boolean useGPU) [0x00000] in <00000000000000000000000000000000>:0 at TensorFlowLite.PoseNet..ctor (System.String modelPath) [0x00000] in <00000000000000000000000000000000>:0 at PoseNetSample.Start () [0x00000] in <00000000000000000000000000000000>:0

What is the problem? Anything that I can do?

asus4 commented 4 years ago

@marimomo00 Android plugin *.so files are built for only Arm64 CPU for now. Could you try to rebuild the plugin with android_arm option instead of android_arm64?

# Configure the Android SDK path by running configure script at the repository root
./configure

# Build experimental
bazel build -c opt --cxxopt=--std=c++11 --config=android_arm //tensorflow/lite/experimental/c:libtensorflowlite_c.so

# Build GPU delegate
bazel build -c opt --config android_arm --copt -Os --copt -DTFLITE_GPU_BINARY_RELEASE --copt -fvisibility=hidden --linkopt -s --strip always //tensorflow/lite/delegates/gpu:libtensorflowlite_gpu_delegate.so
marimomo00 commented 4 years ago

Thanks for your prompt reply.

I will have a try.

On Mon, Apr 6, 2020 at 6:46 PM Koki Ibukuro notifications@github.com wrote:

@marimomo00 https://github.com/marimomo00 Android plugin *.so files are built for Arm64 CPU for now. Could you try to rebuild the plugin with android_arm option instead of android_arm64?

Configure the Android SDK path by running configure script at the repository root

./configure

Build experimental

bazel build -c opt --cxxopt=--std=c++11 --config=android_arm //tensorflow/lite/experimental/c:libtensorflowlite_c.so

Build GPU delegate

bazel build -c opt --config android_arm --copt -Os --copt -DTFLITE_GPU_BINARY_RELEASE --copt -fvisibility=hidden --linkopt -s --strip always //tensorflow/lite/delegates/gpu:libtensorflowlite_gpu_delegate.so

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/asus4/tf-lite-unity-sample/issues/11#issuecomment-609719138, or unsubscribe https://github.com/notifications/unsubscribe-auth/APCOC73JOZ27CRVMMIMDIJTRLGXH7ANCNFSM4MCEXEDQ .

gblue1223 commented 4 years ago

I wanna share my experience about Bazel building. First of all, I've built with ''tensorflow-2.1.0" and ''bazel-0.29.1''. And I ran ''./configure'' and everything leave as default but set options regarding Android.

Then I ran the command as @asus4 said. You have to make sure about tensorflow and bazel version. It is very sensitive.

manena commented 4 years ago

I'm sorry I'm new to building so files. I would like to build for android_arm. I'm working on MAC OS Catalina and have no idea if these are commands to run from the shell, what directory I should be in and what would I need to install in order to be able to build.

Can you give me some guidance?

Thanks in advance

marimomo00 commented 4 years ago

@manena There are instruction on building tensorflow. https://www.tensorflow.org/install/source

However, I got lots of error when compiling on windows. I'm still struggling on building android_arm. I've opened another issue and hope someone could help.

https://github.com/tensorflow/tensorflow/issues/38525

@gblue1223 I've tried ''tensorflow-2.1.0" and ''bazel-0.29.1'', but with error. Do you build on Windows or MAC OS?

gblue1223 commented 4 years ago

@marimomo00 I've built on Ubuntu. Since Tensorflow more familiar with Linux, you should try on Linux OS.

manena commented 4 years ago

Thanks @marimomo00 i’ll try. In the meanwhile @gblue1223: would it be possible for you to share with us the .so files you have built? It would be very helpful!

Regards and I hope all of you and your families are fine!

gblue1223 commented 4 years ago

@manena Here is the .so files. Good luck~

Freeverc commented 4 years ago

I've built libtensorflowlite_c.so for ARMv7,but I can not use it in your samples. The result on my phone is pure white with no images.How can I use it in ARMv7? I've changed the Target Architectures.

emusiceducation123 commented 4 years ago

I built for ARMv7 as well. When it runs, log shows: 08-29 11:01:18.646 3872 4085 I tflite : Initialized TensorFlow Lite runtime. 08-29 11:01:20.242 7703 7723 E Unity : Unable to find libtensorflowlite_gpu_delegate 08-29 11:01:20.244 7703 7723 E Unity : Unable to find tensorflowlite_gpu_delegate 08-29 11:01:20.259 7703 7723 E Unity : Unable to find libtensorflowlite_c

mathtasatlime commented 3 years ago

Does anybody have a working build auf 2.4.0 for armv7 ?

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.