microsoft / onnxruntime-inference-examples

Examples for using ONNX Runtime for machine learning inferencing.
MIT License
1.19k stars 335 forks source link

Facing Errors while running example through dsp #170

Open Animesh081005 opened 1 year ago

Animesh081005 commented 1 year ago

@HectorSVC I have gone through the steps at https://github.com/microsoft/onnxruntime-inference-examples/tree/main/c_cxx/Snpe_EP, but I am facing following errors in running the snpe_ep_sample --dsp chairs.raw command.

Error:- linker : normalize_path - invalid input: "'/data/local/TMP/snpeexample'", the input path should be absolute

snpe_ep_example: vendor/qcom/proprietary/adsprpc/src/log_config.c:268:Error 0x200: fopen failed for /vendor/lib/rfsa/adsp/snpe_ep_sample.farf. (No such file or directory)

snpe_ep_example: vendor/qcom/proprietary/adsprpc/src/log_config.c:268:Error 0x200: fopen failed for /vendor/dsp/cdsp/snpe_ep_sample.farf. (No such file or directory)

snpe_ep_example: vendor/qcom/proprietary/adsprpc/src/log_config.c:268:Error 0x200: fopen failed for /vendor/dsp/snpe_ep_sample.farf. (No such file or directory)

I have tried it on Samsung galaxy S22 ultra device and with following versions:- NDK version 25.1.8937393 SNPE 1.66.0.3729

Please let me know if I should change anything or if there are any other pre-requisite for successfully running the example.

HectorSVC commented 1 year ago

It's more like something wrong with the path. Have you checked that you have everything in folder /data/local/TMP/snpeexample? should it be /data/local/tmp/snpeexample?

Animesh081005 commented 1 year ago

@HectorSVC Correction: The path is /data/local/tmp/snpeexample

And /data/local/tmp/snpeexample folder contains the following files:

libcalculator_skel.so libsnpe_dsp_v65_domains_v2_skel.so libsnpe_dsp_v66_domains_v2_skel.so libSnpeHtpV68Skel.so libSnpeHtpV69Skel.so libc++_shared.so libcalculator.so libcalculator_htp.so libhta.so libPlatformValidatorShared.so libSNPE.so libsnpe_dsp_domains_v2.so libSnpeHtpPrepare.so libSnpeHtpV68Stub.so libSnpeHtpV69Stub.so libonnxruntime.so snpe_ep_sample snpe_inception_v3.onnx chairs.raw imagenet_slim_labels.txt

Getting the same following error: Error:- linker : normalize_path - invalid input: "'/data/local/tmp/snpeexample'", the input path should be absolute

snpe_ep_example: vendor/qcom/proprietary/adsprpc/src/log_config.c:268:Error 0x200: fopen failed for /vendor/lib/rfsa/adsp/snpe_ep_sample.farf. (No such file or directory)

snpe_ep_example: vendor/qcom/proprietary/adsprpc/src/log_config.c:268:Error 0x200: fopen failed for /vendor/dsp/cdsp/snpe_ep_sample.farf. (No such file or directory)

snpe_ep_example: vendor/qcom/proprietary/adsprpc/src/log_config.c:268:Error 0x200: fopen failed for /vendor/dsp/snpe_ep_sample.farf. (No such file or directory)

HectorSVC commented 1 year ago

Does native SNPE work on your device?

Animesh081005 commented 1 year ago

@HectorSVC

I am trying to execute "snpe_ep_sample" in Samsung Galaxy S22 model. I am getting above mentioned Error. Could you please guide how to check native SNPE is working fine or not..

Also I am getting below Crash,

12-01 14:18:41.738 10420 10430 I snpe_ep_sample: vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:849: Successfully opened file /vendor/dsp/cdsp/libc++abi.so.1 12-01 14:18:41.794 10420 10420 I snpe_ep_sample: vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:1490: remote_handle64_open: Successfully opened handle 0x37e70150 for file:///libSnpeHtpV69Skel.so?snpe_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 3 12-01 14:18:41.798 10420 10420 I onnxruntime: [I:onnxruntime:test, snpe_lib.cc:140 InitializeSnpe] setPerformanceProfile to SUSTAINED_HIGH_PERFORMANCE for Android environment! --------- beginning of crash 12-01 14:18:41.803 10420 10420 F libc : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 10420 (snpe_ep_sample), pid 10420 (snpe_ep_sample) 12-01 14:18:41.880 10439 10439 I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstoneProto : : 12-01 14:18:41.929 10439 10439 F DEBUG : backtrace: 12-01 14:18:41.929 10439 10439 F DEBUG : #00 pc 0000000000053794 /apex/com.android.runtime/lib64/bionic/libc.so (abort+168) (BuildId: e278775533ac9a2eaf2d2fbf893a855f) 12-01 14:18:41.929 10439 10439 F DEBUG : #01 pc 00000000000b9ff4 /data/local/tmp/snpeexample/libc++_shared.so (__cxxabiv1::readEncodedPointer(unsigned char const*, unsigned char)+340) (BuildId: b174a220cd9b5431ae81136245506ebcfdbaae19) 12-01 14:18:41.929 10439 10439 F DEBUG : #02 pc 00000000000b95d8 /data/local/tmp/snpeexample/libc++_shared.so (cxxabiv1::scan_eh_tab(cxxabiv1::(anonymous namespace)::scan_results&, _Unwind_Action, bool, _Unwind_Exception, _Unwind_Context*)+248) (BuildId: b174a220cd9b5431ae81136245506ebcfdbaae19) 12-01 14:18:41.929 10439 10439 F DEBUG : #03 pc 00000000000b93f0 /data/local/tmp/snpeexample/libc++_shared.so (__gxx_personality_v0+216) (BuildId: b174a220cd9b5431ae81136245506ebcfdbaae19) 12-01 14:18:41.929 10439 10439 F DEBUG : #04 pc 0000000000a76b2c /data/local/tmp/snpeexample/libonnxruntime.so (BuildId: 80698b11d6d99a52a8360316ff623c68c830e607)

Kindly guide how to run "snpe_ep_sample".

P.S : "snpe_ep_sample" is working fine for CPU , crash is happening only case of DSP.

HectorSVC commented 1 year ago

Here are some tutorials you can try: https://developer.qualcomm.com/sites/default/files/docs/snpe/usergroup7.html Also try with snpe-platform-validator to make sure DSP is available and setup correctly. https://developer.qualcomm.com/sites/default/files/docs/snpe/tools.html#tools_snpe-platform-validator I think your Samsung galaxy S22 should have DSP, but maybe too old.

Animesh081005 commented 1 year ago

@HectorSVC Thank you for sharing the tutorials !!! I have tried snpe-platform-validator , it is working fine

_PF_VALIDATOR: DEBUG: starting calculator test
PF_VALIDATOR: DEBUG: Loading HTP stub: libcalculator_htp.so
PF_VALIDATOR: DEBUG: Successfully loaded DSP library - 'libcalculator_htp.so'.  Setting up pointers.
PF_VALIDATOR: DEBUG: Success in executing the sum function
Unit Test on the runtime DSP: Passed.
SNPE is supported for runtime DSP on the device.
PF_VALIDATOR: DEBUG: Calling PlatformValidator->IsRuntimeAvailable
PF_VALIDATOR: DEBUG: CPU side validation passed.

PF_VALIDATOR: DEBUG: starting calculator test
PF_VALIDATOR: DEBUG: Loading HTP stub: libcalculator_htp.so
PF_VALIDATOR: DEBUG: Successfully loaded DSP library - 'libcalculator_htp.so'.  Setting up pointers.
PF_VALIDATOR: DEBUG: Success in executing the sum function
Runtime DSP Prerequisites: Present._

And I have tried snpe-net-run for this example - https://developer.qualcomm.com/sites/default/files/docs/snpe/tutorial_inceptionv3.html

It is also working fine.

_snpe-net-run --container inception_v3_quantized.dlc --input_list target_raw_list.txt --use_dsp                      <
-------------------------------------------------------------------------------
Model String: N/A
SNPE v1.66.0.3729
-------------------------------------------------------------------------------
Processing DNN input(s):
cropped/notice_sign.raw
Processing DNN input(s):
cropped/trash_bin.raw
Processing DNN input(s):
cropped/chairs.raw
Processing DNN input(s):
cropped/plastic_cup.raw_

But "snpe_ep_sample" is still not working and it is showing the same error.

_11-29 00:29:22.773 17614 17614 I snpe_ep_sample: vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:1490: remote_handle64_open: Successfully opened handle 0x75e5d510 for file:///libSnpeHtpV69Skel.so?snpe_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 3
11-29 00:29:22.776 17614 17614 I onnxruntime:  [I:onnxruntime:test, snpe_lib.cc:140 InitializeSnpe] setPerformanceProfile to SUSTAINED_HIGH_PERFORMANCE for Android environment!

11-29 00:29:22.852 17625 17625 F DEBUG   : backtrace:
11-29 00:29:22.852 17625 17625 F DEBUG   :       #00 pc 0000000000053794  /apex/com.android.runtime/lib64/bionic/libc.so (abort+168) (BuildId: 3d626fb2601d1232de382ca7a6acde16)
11-29 00:29:22.852 17625 17625 F DEBUG   :       #01 pc 00000000000b9ff4  /data/local/tmp/snpeexample/aarch64-android-clang8.0/lib/libc++_shared.so (__cxxabiv1::readEncodedPointer(unsigned char const**, unsigned char)+340) (BuildId: b174a220cd9b5431ae81136245506ebcfdbaae19)
11-29 00:29:22.852 17625 17625 F DEBUG   :       #02 pc 00000000000b95d8  /data/local/tmp/snpeexample/aarch64-android-clang8.0/lib/libc++_shared.so (__cxxabiv1::scan_eh_tab(__cxxabiv1::(anonymous namespace)::scan_results&, _Unwind_Action, bool, _Unwind_Exception*, _Unwind_Context*)+248) (BuildId: b174a220cd9b5431ae81136245506ebcfdbaae19)
11-29 00:29:22.852 17625 17625 F DEBUG   :       #03 pc 00000000000b93f0  /data/local/tmp/snpeexample/aarch64-android-clang8.0/lib/libc++_shared.so (__gxx_personality_v0+216) (BuildId: b174a220cd9b5431ae81136245506ebcfdbaae19)
11-29 00:29:22.852 17625 17625 F DEBUG   :       #04 pc 0000000000a76b2c  /data/local/tmp/snpeexample/aarch64-android-clang8.0/lib/libonnxruntime.so (BuildId: 80698b11d6d99a52a8360316ff623c68c830e607)_

There could be any problem with libonnxruntime.so ?

HectorSVC commented 1 year ago

Could you try comment out the code: snpe_builder.setPerformanceProfile(zdl::DlSystem::PerformanceProfile_t::SUSTAINED_HIGH_PERFORMANCE); https://github.com/microsoft/onnxruntime/blob/c1cc1d5859da460f2320389252da3690dd2dfbbc/onnxruntime/core/providers/snpe/snpe_lib.cc#L141 Then rebuild Onnxruntime and the example. Maybe it does not work for your device.

Animesh081005 commented 1 year ago

@HectorSVC I have tried commenting out the code from the snpe_lib.cc file and then rebuilding the onnxruntime and then the example. I am getting the below error logs in that case. I guess just the setPerformanceProfile part is removed from the latest logs.

11-29 21:06:26.402 29751 29756 I snpe_ep_sample: vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:849: Successfully opened file /vendor/dsp/cdsp/libc++.so.1
11-29 21:06:26.407 29751 29756 I snpe_ep_sample: vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:849: Successfully opened file /vendor/dsp/cdsp/libc++abi.so.1
11-29 21:06:26.467 29751 29751 I snpe_ep_sample: vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:1490: remote_handle64_open: Successfully opened handle 0xa4e36d10 for file:///libSnpeHtpV69Skel.so?snpe_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 3
:
:
11-29 21:06:26.548 29761 29761 F DEBUG   : backtrace:
11-29 21:06:26.548 29761 29761 F DEBUG   :       #00 pc 0000000000053794  /apex/com.android.runtime/lib64/bionic/libc.so (abort+168) (BuildId: 3d626fb2601d1232de382ca7a6acde16)
11-29 21:06:26.548 29761 29761 F DEBUG   :       #01 pc 00000000000b9ff4  /data/local/tmp/snpeexample_latest/libc++_shared.so (__cxxabiv1::readEncodedPointer(unsigned char const**, unsigned char)+340) (BuildId: b174a220cd9b5431ae81136245506ebcfdbaae19)
11-29 21:06:26.548 29761 29761 F DEBUG   :       #02 pc 00000000000b95d8  /data/local/tmp/snpeexample_latest/libc++_shared.so (__cxxabiv1::scan_eh_tab(__cxxabiv1::(anonymous namespace)::scan_results&, _Unwind_Action, bool, _Unwind_Exception*, _Unwind_Context*)+248) (BuildId: b174a220cd9b5431ae81136245506ebcfdbaae19)
11-29 21:06:26.548 29761 29761 F DEBUG   :       #03 pc 00000000000b93f0  /data/local/tmp/snpeexample_latest/libc++_shared.so (__gxx_personality_v0+216) (BuildId: b174a220cd9b5431ae81136245506ebcfdbaae19)
11-29 21:06:26.548 29761 29761 F DEBUG   :       #04 pc 0000000000a7318c  /data/local/tmp/snpeexample_latest/libonnxruntime.so (BuildId: 4b49bad3f01ba46a0ed1863801faba3a42729f72)
Animesh081005 commented 1 year ago

@HectorSVC I am using SNPE version 1.66.0.3729. Can you please suggest NDK version and other important parameters while building the onnxruntime using below command:

build.bat --build_shared_lib --skip_submodule_sync --android --config Release --use_snpe --snpe_root [location-of-SNPE_SDK] --android_sdk_path [location-of-android_SDK] --android_ndk_path [location-of-android_NDK] --android_abi arm64-v8a --android_api [api-version] --cmake_generator Ninja --build_dir build\Android

HectorSVC commented 1 year ago

here's what I used: NDK: android-ndk-r21e android_abi arm64-v8a android_api 27