microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
14.69k stars 2.93k forks source link

[Mobile] QNN SetupBackend fails due to 32-bit library loading in 64-bit environment #22518

Open w11m opened 3 weeks ago

w11m commented 3 weeks ago

Describe the issue

While initializing ONNX Runtime on a mobile device, I encountered an issue with the QNNExecutionProvider failing to load the backend library libQnnHtpVXX.so. The error log indicates that the library is 32-bit, whereas the device and ONNX Runtime are operating in a 64-bit environment.

Here is the error log: [E:onnxruntime:, qnn_execution_provider.cc:296 GetCapability] QNN SetupBackend failed qnn_backend_manager.cc:40 GetQnnInterfaceProviders Unable to load backend, error: dlopen failed: "/vendor/lib/rfsa/adsp/libQnnHtpVXX.so" is 32-bit instead of 64-bit

if there any solution for this or I need to check with the libQnnHtpVXX.so prvider vendor?

To reproduce

Initialize ONNX Runtime on a 64-bit Android device using the QNN execution provider. Attempt to run a model that requires thelibQnnHtpVXX.so backend library. Observe the error indicating failure due to the library being 32-bit in a 64-bit environment.

Urgency

Might be urgent

Platform

Android

OS Version

A15

ONNX Runtime Installation

Built from Source

Compiler Version (if 'Built from Source')

Package Name (if 'Released Package')

None

ONNX Runtime Version or Commit ID

1.16.1

ONNX Runtime API

C++/C

Architecture

ARM64

Execution Provider

Other / Unknown

Execution Provider Library Version

QNN-2.25.7

cloudhan commented 3 weeks ago

Say you have QNN_HOME=/opt/qcom/aistack/qairt/2.26.0.240828, how about just copy your ${QNN_HOME}/lib/aarch64-android/libQnnHtp*.so manually? You then need to prepend your QNN libs dir on device to LD_LIBRARY_PATH and ADSP_LIBRARY_PATH.

w11m commented 3 weeks ago

@cloudhan Thanks for the suggestion! I’ll go ahead and copy the QNN libraries and update the paths. Do I need to replaced the orignal shared lib .so in the device? Or can the libQnnHtp*.so files be located anywhere?

cloudhan commented 3 weeks ago

In principle, they can be located anywhere, but you need to configure the env vars I mentioned previously.