-
Notifications
You must be signed in to change notification settings - Fork 687
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
EngineException when running in GraalVM Native Image #103
Comments
@murphye I made some changes in my branch: https://github.com/frankfliu/djl-demo/tree/quarkus/covid19-detection-quarkus Now EngineException is gone. But I'm still facing java.lang.UnsatisfiedLinkError. This was the same static initialization issue. I tried to add --initialize-at-run-time and --initialize-at-build-time, doesn't seem work. All the static initializer are not executed at all. I'm not sure if I add these parameter correctly or not. |
@frankfliu Did you push your changes to your branch? Can you add link to your commit? Now that we have overcome this issue, I can try again with my original That being said it would be good to know how they got this working without |
Here is my commit: frankfliu/djl-demo@1f3ef47 |
@murphye I made some progress.
I'm not sure how I can continue on this. Can you bring this to quarkus team? |
I made some progress as well. but on a different path. I am able to compile and run in Native, but the TensorFlow libs are not being loaded correctly.
I am trying to bundle with the executable after copying to the target directory:
I will look at your Pull Request and do some further analysis. It seems to be more complicated than it should be to get this working. My other example project was fairly straightforward. https://github.com/murphye/quarkus-tensorflow-inception |
@frankfliu Per your issue, try adding this to
|
Per oracle/graal#1163, I have read that PNG works, but JPG does not. I have used Apache Commons Image in my other project, but it has serious limitations if the JPG is compressed too much, it cannot read the file. |
@murphye I made some changes to workaround image problem. Using apache commons imaging seems work. commons images doesn't support save JPG file and some of JPG file cannot load properly. But it works in general. See my PR: deepjavalibrary/djl-demo#55 I will try quarkus.ssl.native=true for quarkus project |
@murphye I tried quarkus.ssl.native=true, it doesn't work, still got java.lang.ClassNotFoundException: io.netty.internal.tcnative.SSLPrivateKeyMethod, I even tried add this to resource-config.json and jni-config.json, no luck. |
@frankfliu I will research. Cannot find any relevant GitHub issues. Possibly a conflict with JNI config for TensorFlow & Netty? I have concerns that there is too much configuration in the solution. It may be good to find other example of using JavaCPP with Native Image (without DJL) as a baseline. This would be good to examine |
@frankfliu There is something called In other words, all of the extra config shouldn't be necessary. That is all I know for now, based on some quick research. |
@murphye I made some changes to make DJL GraalVM friendly: https://github.com/frankfliu/djl/tree/graalvm, with this change you don't need adding configuration. You can see this demo project, it's working by default now: https://github.com/frankfliu/djl-demo/tree/graalvm/graalvm It seems quarkus did something strange and changed default build behavior. With the same dependency, I got following error:
I don't know how to found offending class with the error message. |
(Edited comment for better response)
I see that you have it here. https://github.com/frankfliu/djl-demo/blob/quarkus/pneumonia-detection-quarkus/src/main/resources/application.properties#L5 |
@frankfliu Do you have all your latest code committed to DJL and demo project? I will take another look at this next week. |
@murphye I'm done on my side:
|
@frankfliu Thanks I will try to look in next couple of days. Seems like we are getting closer however. I am optimistic considering I had previous TensorFlow demo working in Quarkus. |
I took some time off, and have also been sick. Will return to this as soon as possible. |
OK... getting the latest code so I can test. I noticed there is aa PMD error causing build to fail.
https://pmd.github.io/latest/pmd_rules_java_multithreading.html#nonthreadsafesingleton
|
Ok, I was able to replicate the error related to This is actually related to an error that I had previously on my prior TensorFlow demo, where I for some reason needed to add dependency to get TensorFlow working: There must be some hidden dependency on Adding this dependency allowed the native build to complete:
|
Ok, so this is what I get when I run the executable and hit the
I then get a pop up window from Mac OS asking me to install Java 6! Weird, right? Update: Upon some research, I found this is related to JNI linking to Java libraries in Mac OS and it may require some change to how TensorFlow is linked, but I am not sure. I did not have this issue previously with the TensorFlow native libraries from the TensorFlow project. |
As an alternative, I ran the Docker-based build using these commands:
Unfortunately I get errors:
|
@murphye My college get the same 'No Java runtime present, requesting install." error on mac. |
After I added netty dependency and made some configuration change, I'm able to build native image. See my branch: https://github.com/frankfliu/djl-demo/blob/quarkus/pneumonia-detection-quarkus/src/main/resources/application.properties#L4-L9 However, it crash at runtime. The tensorflow share library is loaded successfully, DJL TfEngine is also loaded properly. But it hit segfault in javacpp. |
Here are my last settings... give a try and see:
|
@murphye I'm able to make PyTorch Engine work. See: deepjavalibrary/djl-demo#84 TensorFlow Engine is still crash at JNI level. I think it related to reflection at JNI code. |
|
DJL with tensorflow engine is work with quarkus now. see: https://github.com/aws-samples/djl-demo/tree/master/quarkus |
Description
Please see this updated project: https://github.com/murphye/djl-demo/blob/master/pneumonia-detection-quarkus/README.md
I have two endpoints:
/detect
will attempt to run the model, and will fail with the following error:/check
will print out information showing that the TensorFlow Engine has been loaded properly.There is a contradiction of information here as TensorFlow Engine is loading, but still doesn't work. This only occurs when running in Native mode, as JVM mode is OK
I am not sure how to proceed. I suggest trying to add more debugging info to DJL to understand what is happening. Quarkus team will have debugger support soon.
How to Reproduce?
See instructions https://github.com/murphye/djl-demo/blob/master/pneumonia-detection-quarkus/README.md
Run the two endpoints and observe the logs.
What have you tried to solve it?
These configs enable the ServiceLoader mechanism:
Also see https://github.com/murphye/djl-demo/blob/master/pneumonia-detection-quarkus/src/main/resources/application.properties
Environment Info
Using Maven rather than Gradle as it provides error messages that Gradle does not for Native compilation. Using Mac and GraalVM 20.1.0 with Quarkus 1.5.1.Final
The text was updated successfully, but these errors were encountered: