-
Notifications
You must be signed in to change notification settings - Fork 661
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
TensorFlow engine not found when exported to a runnable jar file #940
Comments
@macster110 You also need include |
I've updated the issue to add a little more clarity. |
@macster110 Based on your description, it looks like your are trying to create a fat jar and include everything in the fat jar.
When you merge the two jar file into single fat jar, one of the file get override (depends on your merge policy). The only workaround if you manually merge this file and added into your fat jar. |
Thanks @frankfliu. I'll check out what's going on with jpam. Does this mean that there is no easy way to bundle two engines in one jar using djl? If this is the case, what is the recommended way to structure and then export a project using multiple engines and djl? |
The Java service loader is a common pattern and there seem to be other solutions existing. A quick search turned up:
|
Thanks @zachgk . After the diagnosis of the issue from @frankfliu I managed to get the test project working by exporting in Eclipse and selecting "package required libraries into generated jar" instead of "extract packaged libraries into generated jar". The MAVEN shade plugin should be able to deal with this but I have been unsuccessful so far in getting it to work. I will post the solution here when I do. Thanks again for all the help on this. |
For reference there are three solutions to this question. Export the jar file without extracting libraries Manually change the META-INF/services/ folder in the jar file
-Save the file and re-zip the contents of the jar file. Rename the zip file to .jar. Everything should work. Let Maven do it all for you Add the Maven shade plugin with the following settings and the jar will be created properly. Note that you must use Maven to generate the jar i.e. set the goal to package shade:shade
|
Description
We have a large project in which we use djl to allow users to load acoustic deep learning models. The djl library is packaged within a single dependency (jdl4pam) generated from a seperate project. During development everything was working great, however, when we packaged the project into a jar file, the TensorFlow based classifiers stopped working returning "Deep learning engine not found" exceptions. Pytorch models were unaffected.
Expected Behavior
It should make no difference running a project from an IDE (in this case Eclipse) or packaging it into a jar file.
Error Message
Exception in thread "main" java.lang.IllegalArgumentException: Deep learning engine not found: TensorFlow
at ai.djl.engine.Engine.getEngine(Engine.java:150)
at ai.djl.Model.newInstance(Model.java:82)
at testjfrog.TestJFrog.main(TestJFrog.java:32)
How to Reproduce?
I've created a minimal project (master branch) which imports a tensorflow "***.pb" file and loads it. The program accepts a path as an argument so any TensorFlow model can be loaded. The available engines are [Tensorflow Pytorch] if run from Eclipse. However, if this is exported to a jar and run from powershell in Windows the only available engine is Pytorch and a the program will throw an exception.
Interestingly if the TensorFlow engine is added before the jdl4pam dependency then the opposite occurs, Tensorflow becomes the only available engine and Pytorch is no longer available.
i.e. this works for Tensorflow models
but it should work using just the jdl4pam dependency.
Steps to reproduce
What have you tried to solve it?
I updated jdl4pam to the latest version of the djl library. I played around with Maven dependencies and found where the issue is (see above) but cannot explain why this occurs?
Environment Info
Windows 10.
Version 10.0.19042 Build 19042
Java 14
(This issue also occurs on MacOS)
The text was updated successfully, but these errors were encountered: