Open GerHelWan opened 1 week ago
I build the python wheel myself by
- downloading the original wheel for linux-arm64-python3.8
- cross-compiling either libhailort and _pyhailo.cpython*.so for android arm64 with the Android NDK llvm clang compiler.
- unzipping the orginal python wheel
- replacing the _pyhailo.cpython*.so with the new cross compiled one
Like I said in #1186, this isn't an approach that I can recommend or assist with. There are so many things that can go wrong with it that I can't even begin to guess at which one has happened here. The purpose of the build-wheel tool is to deal with all of these issues so you don't have to.
We managed to build pyHailoRT using the build-wheel-tool. Some changes of the original source code where necessary (e.g. renaming and copying the _pyhailo.so to right place).
But there is still one thing missing. The _pyhailo.so itself depends on the libhailort.so. We have integrated the libhailort.so into the Android image on the target device.
The libhailort.so is already installed under /system/lib
and system/lib64
.
However, when running our application we get the error that the libhailort.so can't be opened/found.
The error occurs when the _pyhailort.so is loaded.
com.chaquo.python.PyException: ImportError: dlopen failed: library "libhailort.so.4.17.1" not found: needed by /data/data/com.chaquo.python.console/files/chaquopy/AssetFinder/requirements/hailo_platform/pyhailort/_pyhailort.so in namespace classloader-namespace
What would be the best way of deploying dependencies of python module packaged and integrated into an app with chaqouopy?
I now managed to create another package/wheel containing just the libhailort.so.4.17.1.
But here the problem is that the libhailort.so.4.17 depends on libm.so.6. Therefore I needed to comment the dependency check for creating the wheel.
This now leads to the runtime error
com.chaquo.python.PyException: OSError: dlopen failed: library "libm.so.6" not found: needed by /data/data/com.chaquo.python.console/files/chaquopy/AssetFinder/requirements/chaquopy/lib/libhailort.so.4.17.1 in namespace classloader-namespace
which makes totally sense.
Would you recommend to create package/module for libm.so.6? Alternatively I see rebuilding libhailort.so.4.7.11 so that is depends on libm.so or modifying the existing libhailort.so.4.7.11 so that it depends on *libm.so.
What would be the best way of deploying dependencies of python module packaged and integrated into an app with chaqouopy?
- I have also seen, that you provide examples of non-python packages in the packages folder. Would you recommend to create a package for the libhailort here.
Yes, that's the only supported method of including non-Python dependencies of Python packages.
In our case we do not want to create a build.sh for our cmake project.
All the build.sh has to do is call cmake
and make
. But running it through build-wheel will ensure CMake is set up correctly for Android. For an example, see the recipe for chaquopy-crc32c
, and google-crc32c
which depends on it.
But here the problem is that the libhailort.so.4.17 depends on libm.so.6
libm.so.6 is a Linux library name – the Android name is just libm.so. This probably means you didn't really compile it for Android at all. Using build-wheel should fix this.
If you need any more help with this, please create a fork of this repository, commit your recipes along with any other changes you've made, and post a link here.
Chaquopy version
version: 15.0.1
Devices or emulators where the issue happens
NXP IMX8
Relevant parts of your code
Describe your issue
I want to integrate the pyHailoRT module for neural network inference into my chaquopy project.
However when import that module I get an module not found error.
Further I get a warning while building the app that
hailort-17.0
is not compatible withnumpy 1.19.5
which is installed by default for python 3.8 (which is my target python version). But the build succeeds. However at runtime I get the module import error see above. Further I noticed that the folder:/data/data/com.chaquo.python.console/files/chaquopy/AssetFinder/requirements
does contains thehailo_platform
folder only a folder for the tutorial assetshailo_tutorials
. What triggers the copy of the shared libraries and necessary assests in order to import and use a module? I tried to manfully copy thehailo_platform
after build. But the module import error stills persists.When upgrading to python 3.10 (also updating numpy to 1.23.0 and hailort-17.0 to python 3.10) I get another issue during the build. The build fails then with:
Value Error: invalid literal for int() with base 10
.HailoRT is the SDK for running inference of neural networks on the low power hailo ai accelerators. https://github.com/hailo-ai/hailort https://hailo.ai
In order that everything works fine
must be available for the target platform which is android arm64 in the case of the NXP imx8.
Everything on that list is adjusted and cross compiled As either the libhailort (pre-built c++ examples) and hailortcli are working the problem I experience has nothing to do with that components I guess.
I build the python wheel myself by