Skip to content
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

ONNXruntime lib open failed due to 64-bit #2880

Closed
3 of 5 tasks
ktprms23 opened this issue Aug 18, 2023 · 2 comments
Closed
3 of 5 tasks

ONNXruntime lib open failed due to 64-bit #2880

ktprms23 opened this issue Aug 18, 2023 · 2 comments
Labels

Comments

@ktprms23
Copy link

Checklist

  • the issue is indeed a bug and not a support request
  • issue doesn't already exist: https://github.com/kivy/python-for-android/issues
  • I have a short, runnable example that reproduces the issue
  • I reproduced the problem with the latest development version (p4a.branch = develop)
  • I used the grave accent (aka backticks) to format code or logs when appropriated

Versions

  • Python: 3.7
  • OS: Ubuntu 18.04
  • Kivy: 2.1.0
  • Cython: 3.0.0
  • OpenJDK: 11.0.18

Description

We are trying to build a project with the onnxruntime library. Due to the onnxruntime is not on the recipes list so it will be build with the pip command by default.

The apk can be generated successfully but will crashed when it try to load the onnxruntime lib due to the lib is 64-bit.

Does anyone have idea to build this library? From the onnxruntime document we can build a standalone libonnxruntime.so, but it is not suitable to use for our project.

buildozer.spec

Command:
We use p4a to generate the apk so there is no buildozer.spec file.

p4a apk --private ./ --requirements=python3,kivy,...,.......,onnxruntime --bootstrap=sdl2 --arch=armeabi-v7a --package=example.python2 --name "test_python2" --dist_name="test_python2" --ndk_dir=... --sdk_dir=... --release --android-api 30 --version 1.1

Logs

The app will crash with the following log.

07-28 04:15:59.246  3478  3567 I python  :  Traceback (most recent call last):
07-28 04:15:59.246  3478  3567 I python  :    File "/home/davidpc/projects/python/test_python/test_python2/main.py", line 6, in <module>
07-28 04:15:59.248  3478  3567 I python  :    File
"/home/davidpc/.local/share/python-for-android/build/python-installs/test_python/armeabi-v7a/onnxruntime/__init__.py", line 55, in <module>
07-28 04:15:59.249  3478  3567 I python  :    File "/home/davidpc/.local/share/python-for-android/build/python-installs/test_python/armeabi-v7a/onnxruntime/__init__.py", line 23, in <module>
07-28 04:15:59.249  3478  3567 I python  :    File "/home/davidpc/.local/share/python-for-android/build/python-installs/test_python/armeabi-v7a/onnxruntime/capi/_pybind_state.py", line 33, in <module>
07-28 04:15:59.250  3478  3567 I python  :  ImportError: dlopen failed: "/data/data/example.python2/files/app/_python_bundle/site-packages/onnxruntime/capi/onnxruntime_pybind11_state.so" is 64-bit instead of 32-bit
07-28 04:15:59.250  3478  3567 I python  : Python for android ended.

We check the so file and it seems the onnxruntime_pybind11_state.so was built with host compiler.

# file onnxruntime_pybind11_state.so
onnxruntime_pybind11_state.so: ELF 64-bit LSB shared object, X86-64, version 1 (SYSV) dynamically linked, BuildID=......
@RobertFlatt
Copy link
Contributor

so it will be build with the pip command by default.

This assumption is incorrect, that is why recipes exist.

onnxruntime_pybind11_state.so: ELF 64-bit LSB shared object, X86-64, version 1 (SYSV) dynamically linked, BuildID=......

https://github.com/Android-for-Python/Android-for-Python-Users#64-bit-instead-of-32-bit
This binary was downloaded from Pypi by pip (and not built)

Cython: 3.0.0

See the Buildozer install instructions

https://onnxruntime.ai/

Your options are either create a recipe or use Pyjnius and the Java api.

Any further questions should be directed to the user groups.

@misl6 misl6 added the support label Aug 22, 2023
@github-actions
Copy link

👋 We use the issue tracker exclusively for bug reports and feature requests. However, this issue appears to be a support request. Please use our support channels to get help with the project.

If you're having trouble installing or using python-for-android, maybe you could be interested in our quickstart guide.

Let us know if this comment was made in error, and we'll be happy to reopen the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants