onnxruntime: Problems with predictions on MacBook Air with M1 chip in Java project based on Maven

I have the following problem:

I’m using ONNX runtime in version 1.8.1 in the Java project with Maven.

When I invoke:

final OrtEnvironment environment = OrtEnvironment.getEnvironment();

then I get an error:

java.lang.NoClassDefFoundError: Could not initialize class ai.onnxruntime.OrtEnvironment

and I cannot perform prediction.

It works fine on Linux on different distros, but I have problems with executing it on MacBook Air with M1 chip.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21 (13 by maintainers)

Most upvoted comments

@Craigacp @snnn I compiled onnxruntime on my Macbook with the command ./build.sh --build_java and in the java/build/libs/onnxruntime-1.11.0.jar inside this *.jar file, in ai/onnxruntime/native/osx-arm64/ directory there are files libonnxruntime.dylib and libonnxruntime4j_jni.dylib, so according to your comments, this *.jar should work with java projects on Macbook with M1 chip. Nevertheless, I haven’t tried to add this custom *.jar file to my project yet. I’ll check it later.