-
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] Bug in android implementation for loading large onnx models #19599
Comments
@Craigacp any thoughts? Feels like duplicating the model bytes in memory is coming up a few times lately with models getting much bigger. I'm definitely not a Java expert so I don't know what the best approach is to avoid that happening. If ORT can read from a path on Android with no additional logic that might be the best general solution to recommend/implement. IIRC passing raw bytes in is ineffective in reducing memory as we have to call
|
I can add a Java session constructor which accepts a I agree that if the native code can read from a filesystem path on Android then we should expose that too, but it's already exposed in Java & Android so maybe that's just a react native problem? |
This issue has been automatically marked as stale due to inactivity and will be closed in 30 days if no further activity occurs. If further support is needed, please provide an update and/or more details. |
#20062) ### Description Adds support for constructing an `OrtSession` from a `java.nio.ByteBuffer`. These buffers can be memory mapped from files which means there doesn't need to be copies of the model protobuf held in Java, reducing peak memory usage during session construction. ### Motivation and Context Reduces memory usage on model construction by not requiring as many copies on the Java side. Should help with #19599.
Describe the issue
The current code tries to load the file on the JVM heap, before passing it to the native code, resulting in unable to load large onnx files on Android due to limited jvm heap.
Can be fixed by commenting out the load from assets section in
OnnxruntimeModule.java
:This disables loading from assets. Perhaps consider adding more logic here that bypasses the JVM heap if the uri is from disk.
To reproduce
Load any large onnx file greater than 500MB on Android
Urgency
No response
Platform
Android
OS Version
Android 14
ONNX Runtime Installation
Built from Source
Compiler Version (if 'Built from Source')
No response
Package Name (if 'Released Package')
None
ONNX Runtime Version or Commit ID
1.16
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: