-
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
Problems with predictions on MacBook Air with M1 chip in Java project based on Maven (even on onnxruntime 1.11.0 - latest at this moment) - no osx-aarch64 dir in the native runtimes dir #11054
Comments
That PR didn't make it into the 1.11 release, and it turns out the packaging was broken for arm64 targets before it. If you compile 1.11.0 from source on an M1 and then change the path inside the jar file from |
Ok, thank you for the quick response @Craigacp . I'll check this fix after the next release or alternatively with jar compiled from the master branch. |
I could not build onnx runtime for Java on MacBook Air M1 on the latest master branch :-(. First, I invoked:
Then I invoked:
and I got the following log:
|
I usually build it with |
Yes, I upgraded XCode. I'm using it for iOS development and I try to keep it updated. I didn't know it's related to onnxruntime build. |
ONNX Runtime uses the compilers & system headers it installs, but if it's working for iOS development it should have enabled everything. Try completely deleting the |
I used your params from the previous comment and it's building :-), so I guess this is the correct way to do it. I'll post an update when the build will finish. |
Ok, it was built on my machine and inside the jar there is a path: Do you plan to release this version to the Maven Central repository in the nearest days? |
I think it'll land in the next release whenever that comes, but |
I meant a new version - not updating the current one, but ok, I'll wait for the release. |
Targeting 1.12 for including this build in the Maven pkg. |
Thanks for the reply @faxu. Can you tell when can I expect |
We just released 1.11, so it will be a few months. |
Ok, thank you for the reply. I'll wait for that. Luckily, running my project with onnxruntime on Mac is not critical issue at the moment. |
@Craigacp Hi Adam, is there anyway we can test out the JNI on Linux AARCH64? Not sure if Java has any nightly build at the moment. Also +1 for 1.12 releases with Linux/Mac ARM support, looking forward to it :). |
I don't believe there are nightly builds for Java (or ORT in general), but you should be able to build it yourself on a Linux aarch64 machine. It'll build a jar with just support for that platform, but you can copy in the other platform libraries from the version on Maven Central to make a jar for internal use if you want (make sure you build Linux aarch64 from the right version tag if you want to do this). I don't frequently build it on Linux aarch64, but I build everything on macOS aarch64 last night while working on a feature. |
Thanks for your response. Is there any instruction to build for aarch64 linux? Or it is more like following general build guideline and add |
I build it with this You can find the exact build command used to make the release binaries in the CI scripts, but those keep moving around so I'm not sure which is the correct one to point at. I'm currently building it on a Linux aarch64 VM at the moment, but it's taking a little while to get the environment configured as I've not used this VM for ORT stuff before. I'll report back if there was any additional complexity. |
It built & the tests ran successfully on an Oracle Linux 7 box running on a 4 core Ampere Altra instance. Took a little while to get the machine setup but the build was without incident. |
Nice! For now I will just follow the default build options to see if it can work. If build works, I can probably bundle the JNI so files together with released shared library to have some extra optimization. |
I am trying to use onnx java runtime on an m1 as well. I found you could use x86 flavor of java and things will work. I am currently using: amazon-corretto-15.jdk I can't speak for the speed or whatnot, but at least my test pass now and I can keep working :) I am not planning on deploying to macOS. |
I'd be careful running ONNX Runtime under Rosetta on an M1. I'm not sure if the detection in MLAS assumes all x86 CPUs have AVX instructions or not. If it fails the detection and uses an AVX instruction these are not emulated by Rosetta and can cause an illegal instruction error which will crash the JVM if one is executed under it. |
Hi @faxu! As of 1.12 release, I'm getting this error when using Java package on M1 Mac:
As far as I understand, M1 binaries have been placed into |
@faxu I bumped onnxruntime in my project to
or
When I use my compiled |
I just checked the content and found the |
The fix is fairly clear: Either add an additional check here https://github.com/microsoft/onnxruntime/blob/master/java/src/main/java/ai/onnxruntime/OnnxRuntime.java#L111 for Mac to rename to arm64, or renaming the packaging in cmake. |
Thanks for your comments. I created PR here: #12325 according to your suggestions. Please, review it. |
My PR was closed without merging after discussion because changes need to be done in the other place (inside |
If I understand correctly, this should be fixed by #12335 |
We will publish a patch release to fix this. |
Hi @snnn! Thanks for looking into this! In the newest version (1.12.1) everything works perfect! I'm able to use ONNX Runtime using Java package on M1 Mac. |
@russellrc-keebo yes, it's fixed by #12335. In the version |
Hi,
I reported a bug in #10874 regarding the fact that onnxruntime does not work on MacBook Air with M1 chip in Java project based on Maven. There is also information that this bug is fixed in PR #10981 I upgraded dependency to onnxruntime to version
1.11.0
and I still have exactly the same bug as I reported in that issue regardless of that upgrade.Calling a function:
causes an error:
I see that in project dependencies there is:
/onnxruntime/1.11.0/onnxruntime-1.11.0.jar!/ai/onnxruntime/native/osx-x64
but error occurs anyway
Moreover, when I execute a single test instead of my whole suite, then I get an error:
Probably, the source of the bug is here:
onnxruntime/java/src/main/java/ai/onnxruntime/OnnxRuntime.java
Line 103 in 74eaaad
in the method
initOsArch()
. I debugged it and in my case I see the following params:osx
aarch64
final result of os arch:
osx-aarch64
and then in
init()
method:libraryDirPathProperty
isnull
whereONNXRUNTIME_NATIVE_PATH
isonnxruntime.native.path
Next, in
extractFromResources(String library)
method,resourcePath
is:and there is no such path.
In the path
ai/onnxruntime/native
there are only the following dirs:linux-x64
osx-x64
win-x64
but there is no
osx-aarch64
, which is detected as my arch on MacBook Air with M1 chipThe text was updated successfully, but these errors were encountered: