-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[Mobile] terminating with uncaught exception of type Ort::Exception: ONNX format model is not supported in this build #18271
Comments
You use either onnxruntime-android-1.12.1 or onnxruntime-mobile-1.12.1 not both. onnxruntime-mobile-1.12.1 is a reduced size build that only supports ORT format models and a limited range of opsets and operators. onnxruntime-android-1.12.1 supports ONNX and ORT format models and all the opsets that were implemented when the package was created. Based on the error it sounds like the onnxruntime library from the mobile package is being selected hence the issues loading the model. Is there a reason not to use the latest release of 1.16? 1.12 is somewhat old. |
@skottmckay I apologize for my previous wording error. The reason I am currently using onnxruntime-android-1.12.1 is because it is the version compatible with my model A.
I obtained the pre-built onnxruntime-android-1.16.1 library from the following repository: If you are aware of any potential methods that could cause this error to occur, or any method that I can convert the onnx opset version, please let me know. Thanks |
That error doesn't quite make sense if your app is only using the 1.16.1 onnxruntime-android package. The error message means the header file being used is from ORT 1.16 as it is requesting v16 of the API, but the actual shared library doesn't know about that version which suggest you actually have linked against v1.12.1 libonnxruntime in the app. I'd suggest you make sure you're only referencing onnxruntime-android v1.16.1 and that the libonnxruntime.so included in the app comes from that package. There may be old build artifacts being accidentally included so a clean build might also help. FWIW The error message doesn't actually exist in the 1.16 shared library as the wording was changed. 1.12: onnxruntime/onnxruntime/core/session/onnxruntime_c_api.cc Lines 2578 to 2579 in 7048164
1.16: onnxruntime/onnxruntime/core/session/onnxruntime_c_api.cc Lines 2759 to 2762 in e7a0495
|
Thanks for the infomation, I'll re-check all the build environment and include file again. |
@skottmckay Thank you for point out the problem Despite replacing the .so file and header file, the C++ code was not updated, facing the error
Here is part of the code I'm using
Without modifying the CMakeList.txt, the build succeeds when using onnxruntime-android-1.12.1:shardLIB and Header. However, when using version 1.16.1, I encounter build errors. |
readelf -a libonnxruntime.so readelf of libonnxruntime.so (1.16.2) from https://repo1.maven.org/maven2/com/microsoft/onnxruntime/onnxruntime-android/1.16.2/
|
readelf -a libonnxruntime.so readelf of libonnxruntime.so (1.12.1) from https://repo1.maven.org/maven2/com/microsoft/onnxruntime/onnxruntime-android/1.12.1/
|
I am uncertain if the provided log contains sufficient detail. But in version 1.16.1, the process failed and generated an error log. |
Dear @skottmckay, I regret any inconvenience caused mention you in this matter. Have tried insert code like this also
However, I am currently unable to point out the root cause of the problem. |
Doesn't appear like you're linking correctly against the .so. There are multiple architectures in the android library (32-bit and 64-bit for ARM and AMD64). I would check that you're using the correct one. You can see the symbol in the readelf output for both versions so it exists.
You don't need to call OrtGetApiBase directly in your code - it's used internally by the ORT C++ API. Adding more usage of a missing symbol doesn't affect whether it's found or not. |
@skottmckay I extract the shared lib (.so) from Version 1.12.1
And get the lib from \onnxruntime-android-1.12.1\jni\arm64-v8a Version 1.16.2
And get the lib from \onnxruntime-android-1.16.2\jni\arm64-v8a |
@skottmckay I also checked with readelf of my file
|
Given the output from libonnxruntime.so shows that symbol to be defined and global, that strongly suggests your app is not actually linking against it correctly. I would suggest closely checking the link command to make sure the path to the onnxruntime library is correct and that it is being linked at the correct time. i.e. must be later in the link list than the code that is using ORT, otherwise when libonnxruntime.so is linked there will be no usage of OrtGetApiBase yet and the library will be ignored. |
@skottmckay Now only need modified code due to API changed with version upgrade, close the issue first. |
Describe the issue
I am currently working on a project where I tried with a pre-built shared library, specifically onnxruntime-android-1.12.1 and onnxruntime-mobile-1.12.1, to facilitate the loading of two distinct ONNX models (.onnx files).
These models are described as follows:
Model A:
ONNX Opset Import Version: 16
Model B:
ONNX Opset Import Version: 11
Issue Description:
My challenge arises when attempting to load Model B using the following code snippet:
session = make_unique<Ort::Session>(env.modelBpath.c_str(), sessionOptions);
but For model B i cannot load it, shows "terminating with uncaught exception of type Ort::Exception: ONNX format model is not supported in this build."
Unfortunately, this code results in an unhandled exception with the message:
"ONNX format model is not supported in this build," for Model B."
Troubleshooting Steps Taken:
I have made an attempt to convert Model B to ONNX Opset Import Version 16 using the following Python code:
However, even after this conversion, I am still encountering the same error when trying to load Model B.
Environment Information:
I would greatly appreciate any guidance or information that can help me in diagnosing and resolving this issue. Thank you in advance for your assistance.
To reproduce
As below
Urgency
No response
Platform
Android
OS Version
13
ONNX Runtime Installation
Released Package
Compiler Version (if 'Built from Source')
No response
Package Name (if 'Released Package')
onnxruntime-android
ONNX Runtime Version or Commit ID
1.12.1
ONNX Runtime API
C++/C
Architecture
ARM64
Execution Provider
Default CPU, Other / Unknown
Execution Provider Library Version
No response
The text was updated successfully, but these errors were encountered: