简体   繁体   中英

DJL is unable to find MXNet Engine, troubleshooting doesn't help me

I have now spent way too much time trying to resolve this on my own, but I seem unable to do this on my own. I wanted to try out DJL , looked at some examples and into the tutorial, and was very excited about it because it seems like a very modern, simple and versatile library. However, I ran into a problem I am unable to solve.

DJL proposes using its MXNet Engine as default engine in the tutorial. It is included via the maven dependency ai.djl.mxnet:mxnet-engine:0.5.0 . When running the sample code from the tutorial, I encounter the following error message:

[main] WARN ai.djl.mxnet.engine.MxEngine - Failed to load MXNet native library
java.lang.UnsatisfiedLinkError: Unable to load library 'mxnet':
Das angegebene Modul wurde nicht gefunden.

Das angegebene Modul wurde nicht gefunden.

Das angegebene Modul wurde nicht gefunden.

Native library (win32-x86-64/mxnet.dll) not found in resource path (D:\dev\DJL Test\target\classes;D:\maven\repo\ai\djl\api\0.5.0\api-0.5.0.jar;D:\maven\repo\com\google\code\gson\gson\2.8.5\gson-2.8.5.jar;D:\maven\repo\org\apache\commons\commons-compress\1.20\commons-compress-1.20.jar;D:\maven\repo\ai\djl\basicdataset\0.5.0\basicdataset-0.5.0.jar;D:\maven\repo\ai\djl\model-zoo\0.5.0\model-zoo-0.5.0.jar;D:\maven\repo\ai\djl\mxnet\mxnet-engine\0.5.0\mxnet-engine-0.5.0.jar;D:\maven\repo\net\java\dev\jna\jna\5.3.0\jna-5.3.0.jar;D:\maven\repo\org\slf4j\slf4j-api\1.7.26\slf4j-api-1.7.26.jar;D:\maven\repo\org\slf4j\slf4j-simple\1.7.22\slf4j-simple-1.7.22.jar)
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:302)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:455)
    at com.sun.jna.Library$Handler.<init>(Library.java:192)
    at com.sun.jna.Native.load(Native.java:596)
    at com.sun.jna.Native.load(Native.java:570)
    at ai.djl.mxnet.jna.LibUtils.loadLibrary(LibUtils.java:68)
    at ai.djl.mxnet.jna.JnaUtils.<clinit>(JnaUtils.java:69)
    at ai.djl.mxnet.engine.MxEngine.newInstance(MxEngine.java:45)
    at ai.djl.mxnet.engine.MxEngineProvider.<clinit>(MxEngineProvider.java:21)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:779)
    at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:721)
    at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1394)
    at ai.djl.engine.Engine.initEngine(Engine.java:45)
    at ai.djl.engine.Engine.<clinit>(Engine.java:40)
    at ai.djl.basicdataset.Mnist$Builder.<init>(Mnist.java:175)
    at ai.djl.basicdataset.Mnist.builder(Mnist.java:66)
    at Main.main(Main.java:28)
    Suppressed: java.lang.UnsatisfiedLinkError: Das angegebene Modul wurde nicht gefunden.

        at com.sun.jna.Native.open(Native Method)
        at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:191)
        ... 20 more
    Suppressed: java.lang.UnsatisfiedLinkError: Das angegebene Modul wurde nicht gefunden.

        at com.sun.jna.Native.open(Native Method)
        at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:204)
        ... 20 more
    Suppressed: java.lang.UnsatisfiedLinkError: Das angegebene Modul wurde nicht gefunden.

        at com.sun.jna.Native.open(Native Method)
        at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:265)
        ... 20 more
    Suppressed: java.io.IOException: Native library (win32-x86-64/mxnet.dll) not found in resource path (D:\dev\DJL Test\target\classes;D:\maven\repo\ai\djl\api\0.5.0\api-0.5.0.jar;D:\maven\repo\com\google\code\gson\gson\2.8.5\gson-2.8.5.jar;D:\maven\repo\org\apache\commons\commons-compress\1.20\commons-compress-1.20.jar;D:\maven\repo\ai\djl\basicdataset\0.5.0\basicdataset-0.5.0.jar;D:\maven\repo\ai\djl\model-zoo\0.5.0\model-zoo-0.5.0.jar;D:\maven\repo\ai\djl\mxnet\mxnet-engine\0.5.0\mxnet-engine-0.5.0.jar;D:\maven\repo\net\java\dev\jna\jna\5.3.0\jna-5.3.0.jar;D:\maven\repo\org\slf4j\slf4j-api\1.7.26\slf4j-api-1.7.26.jar;D:\maven\repo\org\slf4j\slf4j-simple\1.7.22\slf4j-simple-1.7.22.jar)
        at com.sun.jna.Native.extractFromResourcePath(Native.java:1095)
        at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:276)
        ... 20 more
Exception in thread "main" ai.djl.engine.EngineException: No deep learning engine found.
Please refer to https://github.com/awslabs/djl/blob/master/docs/development/troubleshooting.md for more details.
    at ai.djl.engine.Engine.getInstance(Engine.java:90)
    at ai.djl.basicdataset.Mnist$Builder.<init>(Mnist.java:175)
    at ai.djl.basicdataset.Mnist.builder(Mnist.java:66)
    at Main.main(Main.java:28)

(Please excuse the partially German error messages, I believe this occurs because MXNet is loaded via JNA and the native windows code uses a different locale. "Das angegebene Modul wurde nicht gefunden" means "the specified module was not found"). Now I do understand what this error is trying to tell me: DJL needs a deep learning engine and tries to load MXNet using JNA, but does not find the DLL. The error message provides a link to the troubleshooting doc of DJL which should resolve my issues. But I couldn't figure it out even with this helper. Here are the steps I considered / tried:

Step 1: First of all, the troubleshooting tells me that MXNet is automatically downloaded / installed or whatever by DJL:

By default, DJL is running on the MXNet engine. We use mxnet-mkl on CPU machines and mxnet-cu102mkl on GPU machines. mkl means Intel-MKLDNN is enabled. cu102 means Nvidia CUDA Toolkit version 10.2 is enabled. You don't need to download and install MXNet separately. It's automatically done when you build the DJL project by running the./gradlew build command.

Now I have never worked with gradle, I always use maven. I did not run the command because if I copy it into the terminal, it tells me that . is not a valid command. Is ./gradlew build automatically executed when I build and run my project in IntelliJ?

Step 2: The troubleshooting file provides some details on the "No deep learning engine found" exception. But I've gone through all steps and now I am even more confused:

  1. The dependency is in my pom.xml and is also loaded and visible in my external libraries
  2. I cannot resolve the "IntelliJ issue" like the troubleshooting tells me. It provides two options. The first one tells me to navigate to references-> Build Execution Deployment -> Build Tools -> Gradle and change the option Build and running using: to Gradle . The problem is that this option does not show up, and I also didn't find it elsewhere. The second option is to "navigate to the MXNet engine resources folder using the project view". This confuses me, because where can I access the MXNet engine resources folder? At least I can tell it is not included in my maven-downloaded jar, should it be there?

Step 3: The troubleshooting doc tells me that I can choose to install MXNet externally, which turned out to be very complicated. But I did it, and I set the MXNET_LIBRARY_PATH environment variable as specified. Still I get the same error.

So after all of this, I really don't know how to approach this problem, so I'm posting this question in order to possibly get some hints by people that are a little more proficient with this than me..

Thank you!

System and Applications:

  • Windows 10 Pro
  • Intel Core i5-7400 CPU, so I installed mkl and the mkl version of mxnet (mxnet-mkl)
  • AMD Radeon R9 380 Series, so no CUDA mxnet for me, sadly
  • mkl version 2020.1
  • MXNet version 1.5.0
  • Java 11 (OpenJDK 11)
  • Maven 3.6.3
  • DJL 0.5.0
  • JNA 5.3.0 (required for DJL)
  • Slf4J api 1.7.26 (required for DJL)
  • Slf4J simple 1.7.22 (required for DJL)
  • IntelliJ IDEA Ultimate 2020.1

You need to include MXNet native dependency: See example project's pom.xml file: https://github.com/awslabs/djl/blob/master/examples/pom.xml#L64-L72

For more detail about MXNet engine dependency, see: https://github.com/awslabs/djl/tree/master/mxnet/mxnet-engine#installation

For Windows, you can use: gradlew build in if you are using CMD, ./ is linux/mac convention, and should work if you are using gitbash on Windows.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM