0

I'm trying to run a dl4j model using GPU instead of CPU. The model runs perfectly well using CPU. So I decided to try CUDA to be able to to take advantage of the my GPU. I followed every step described in here and for the CUDA install I followed the instructions from NVIDIA to install CUDA Toolkit from here. The code compiles ok but I get an error:

Skipped [JCublasBackend] backend (unavailable): java.lang.UnsatisfiedLinkError: C:\Users\albertb\.javacpp\cache\cuda-10.2-7.6-1.5.3-windows-x86_64.jar\org\bytedeco\cuda\windows-x86_64\jnicudart.dll: Can't find dependent libraries
Exception in thread "main" java.lang.ExceptionInInitializerError
    at TestCUDA.run(TestCUDA.java:12)
    at TestCUDA.main(TestCUDA.java:7)
Caused by: java.lang.RuntimeException: org.nd4j.linalg.factory.Nd4jBackend$NoAvailableBackendException: Please ensure that you have an nd4j back-end on your classpath. Please see: https://deeplearning4j.konduit.ai/nd4j/backend
    at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:5094)
    at org.nd4j.linalg.factory.Nd4j.<clinit>(Nd4j.java:270)
    ... 2 more
Caused by: org.nd4j.linalg.factory.Nd4jBackend$NoAvailableBackendException: Please ensure that you have an nd4j backend on your classpath. Please see: https://deeplearning4j.konduit.ai/nd4j/backend
    at org.nd4j.linalg.factory.Nd4jBackend.load(Nd4jBackend.java:221)
    at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:5091)
    ... 3 more

My project was created using Maven on IntelliJ. All the dependencies are ok I guess otherwise the code would not compile. Some back-end dependency or library or install must be missing. May be a version incompatibility is the problem.
The message Please ensure that you have an nd4j backend on your classpath gives me some hint about some back-end jar that must be there. But Maven is supposed to take care of that... as far as I know.

I searched internet for some solution or example or tutorial.. anything !! There are all colones of the same instruction from the links above.

Some technical info:

  • Windows 10
  • Java 1.8 IntelliJ + Maven
  • dl4j 1.0,0-beta7
  • nd4j-cuda-10.2
  • CUDA 11.1 - latest version today

I'll keep trying to solve the problem but I would appreciate any help. Thanks.

Jauhari
  • 13
  • 2
ABFovox
  • 39
  • 4
  • 1
    Which CUDA version did you install? If I go by the link you provided, you installed CUDA 11.x and that won't work with your Java/CUDA build. It appears to be looking for a CUDA 10.2 install. – Robert Crovella Sep 24 '20 at 21:40
  • Ok, so what should I do ? uninstall CUDA and install version 10 or change my POM file to a newer artifact id ? I think the newest Maven dependency available is 10.2, the one that I have now. BTW, the CUDA documentation specify that every version is backward compatible. so.... I'm lost here. – ABFovox Sep 25 '20 at 12:53
  • Using the setup you have, I would install CUDA 10.2. You shouldn't need to uninstall anything. In fact, when installing CUDA 10.2, I would deselect the option to install the driver that is bundled with it. Your driver, installed with CUDA 11.x, will work with a CUDA 10.2 install. I suspect that installing CUDA 10.2 may be the only thing needed to resolve this issue. You can get a CUDA 10.2 installer starting [here](https://developer.nvidia.com/cuda-10.2-download-archive). – Robert Crovella Sep 25 '20 at 12:58
  • Thanks for the answer !!! So you say I can install both CUDAs 11 and 10.2 at the same time ? I believe I should uninstall the one that I have before I install a new one, right? – ABFovox Sep 25 '20 at 13:50
  • **Yes**, You can have them both installed at the same time. You do not need to uninstall CUDA11.x before installing CUDA 10.2. Furthermore, as already stated, when you run the CUDA 10.2 installer, I would deselect the option to install the bundled driver. No uninstall should be necessary. – Robert Crovella Sep 25 '20 at 13:58

2 Answers2

1

You likely have the wrong cuda version installed. The nd4j cuda version is specified in the artifact id like: nd4j-cuda-11.0/10.2.

If you want, you can use the redist artifacts from javacpp for this: https://search.maven.org/artifact/org.bytedeco/cuda-platform-redist/11.0-8.0-1.5.4/jar

This is the latest version for cuda 11. Nd4j just uses javacpp underneath for all of its native interop.

Adam Gibson
  • 3,055
  • 1
  • 10
  • 12
  • I have installed CUDA 11.1, the las version – ABFovox Sep 25 '20 at 12:49
  • I tried to change artifact id to CUDA 11.0... This is what I get: `Could not find artifact org.nd4j:nd4j-cuda-11.0:pom:1.0.0-beta7 in central (https://repo.maven.apache.org/maven2)` – ABFovox Sep 25 '20 at 13:38
  • Please install the exact version, otherwise it won't find the right dll – Adam Gibson Sep 25 '20 at 14:19
  • Ah sorry we only support up to 10.2 for beta7. We'll have cuda 11 next release. You can use oss-sonatype snapshots for 11.0 if you want that. Also note, don't go randomly mixing cuda versions. No software that uses cuda will work if you do that. Or if it does it's by accident. Cuda is by definition not backwards compatible. – Adam Gibson Oct 30 '20 at 00:33
0

I’m resolved it! Now my example working on GeForce3090!!!

Part of My POM:

 org.example
    dl4jCuda
    1.0-SNAPSHOT

        <dependency>
            <groupId>org.deeplearning4j</groupId>
            <artifactId>deeplearning4j-cuda-11.0</artifactId>
            <version>1.0.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.deeplearning4j</groupId>
            <artifactId>deeplearning4j-core</artifactId>
            <version>1.0.0-SNAPSHOT</version>
        </dependency>

Also you need build nd4j-cuda-11.0 from sources and add all *jar and dll files to your project!

Vladimir
  • 1
  • 2