-
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
Not able to load onnx model multilingual-e5-large #21321
Comments
The error shows that the model.onnx_data can not be found. Did you download both the model.onnx and model.onnx_data and save them in the same folder? |
I apologize - you are right. Once specifying: Unfortunately spring AI with ai.onnxruntime still does not work. Now I am getting error: The model has 2,1Gb, I am using 64bit JVM 17 and setting JVM -Xms16g -Xmx16g did not help..... |
You can't load a multi-part model (where there is both |
I am struggling with this issue almost two weeks - unfortunately I amjust onnx beginner.... I java I need to create OrtSession and there are only two constructor options: A) From the single file
B) From protobuf byte array
anyway, in the end you always need to have "one consolidated onnx export" e.g. in some way to "merge" the files I have spend a lot of time to understand the issue, finding that probably the principle is:
Expected resulting structure is without extarnal data, containing just raw_data (example):
I tried to:
final python code is:
Unfortunately: |
You can't combine them into a single file, it won't load as it will be over the file size limit. You can load the onnx file and let it read the onnx_data file from disk in the location it is in, or load in the onnx_data file in python and write the initializers out in something you can easily read in Java then add them to the |
Thank you for reccomendation of addExternalInitializers I have tried following code:
When you uncomment "Create OnnxTensor and use it as OnnxTensorLike" part, I am getting an error: Cannot allocate a direct buffer of the requested size and type, size 1024008192, type = FLOAT I am using Java 17 and added these VM options: -XX:MaxDirectMemorySize=4g -Xmx2g - did not help Going to OrtUtil.java, line 492 I see following condition:
Therefore I have commented "Create OnnxTensor and use it as OnnxTensorLike" part, getting for first largest initializer Raw data offset: 1024008192 It seems, that even here is 2Gb limit (2147483615), and I do not understand why it fails if initializer has 1Gb...what I am doing wrong? |
I was recommended this workaround, which seems to be working (further tests required):
|
I had this issue too. when can fix it? |
You can load in the initializers manually by processing the byte stream from the |
…ining elements of a different type (#21774) ### Description Fixes a bug where the buffer offset and position was incorrectly computed if the user supplied a `ByteBuffer` to `createTensor` but set the type of the tensor to something other than `INT8`. This would be more common if the user was trying to load the initializers from a serialized representation and didn't want to bother with the type information (which is the case in #21321). ### Motivation and Context Partial fix for #21321. The remainder of the fix is to add a helper which allows users to load initializers out of an `onnx_data` file, but that will require adding protobuf as a dependency for the Java API to allow the parsing of an ONNX file separately from the native code. It might be nicer to put that functionality into ORT's C API so it can return the lengths & offsets of the initializers when provided with an ONNX file containing external initializers. We hit this kind of thing in Java more often than other languages as in Java models can be supplied as classpath resources which we can easily read, but not materialize on disk for the ORT native library to read.
Describe the issue
I am trying to use Spring AI for onnx model multilingual-e5-large:
Model is here:
https://huggingface.co/intfloat/multilingual-e5-large/tree/main/onnx
When I have dependencies in build.gradle like (not trying to force new onnxruntime version):
implementation 'org.springframework.ai:spring-ai-transformers'
//implementation group: 'com.microsoft.onnxruntime', name: 'onnxruntime', version: '1.18.0'
I am getting:
ORT_RUNTIME_EXCEPTION - message: Exception during initialization: C:\a_work\1\s\onnxruntime\core\optimizer\initializer.cc:35 onnxruntime::Initializer::Initializer !model_path.IsEmpty() was false. model_path must not be empty. Ensure that a path is provided when the model is created or loaded.
When I have dependencies in build.gradle like (trying to force new onnxruntime version):
implementation 'org.springframework.ai:spring-ai-transformers'
implementation group: 'com.microsoft.onnxruntime', name: 'onnxruntime', version: '1.18.0'
I am getting:
Error code - ORT_FAIL - message: Deserialize tensor onnx::MatMul_3326 failed.GetFileLength for .\model.onnx_data failed:open file model.onnx_data fail, errcode = 2 - unknown error
The code is perfectly working with model all-MiniLM-L6-v2:
https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2/tree/main/onnx
Unfortunately at this moment I do not have any idea, how to resolve this issue. Can you help me?
To reproduce
My configuration is:
Urgency
No response
Platform
Windows
OS Version
11
ONNX Runtime Installation
Released Package
ONNX Runtime Version or Commit ID
1.18.0
ONNX Runtime API
Java
Architecture
X64
Execution Provider
Default CPU
Execution Provider Library Version
No response
The text was updated successfully, but these errors were encountered: