Backends
Hardware setup for Eclipse Deeplearning4j, including GPUs and CUDA.
ND4J works atop so-called backends, or linear-algebra libraries, such as Native nd4j-native and nd4j-cuda-10.2 (GPUs), which you can select by pasting the right dependency into your project’s POM.xml file.
ND4J backends for GPUs and CPUs
You can choose GPUs or native CPUs for your backend linear algebra operations by changing the dependencies in ND4J's POM.xml file. Your selection will affect both ND4J and DL4J being used in your application.
If you have CUDA v9.2+ installed and NVIDIA-compatible hardware, then your dependency declaration will look like:
As of now, the artifactId
for the CUDA versions can be one of nd4j-cuda-9.2
, nd4j-cuda-10.0
, nd4j-cuda-10.1
or nd4j-cuda-10.2
.
You can also find the available CUDA versions via Maven Central search or in the Release Notes.
Otherwise you will need to use the native implementation of ND4J as a CPU backend:
Building for Multiple Operating Systems
If you are developing your project on multiple operating systems/system architectures, you can add -platform
to the end of your artifactId
which will download binaries for most major systems.
Bundling multiple Backends
For enabling different backends at runtime, you set the priority with your environment via the environment variable
Relative to the priority, it will allow you to dynamically set the backend type.
CuDNN
See our page on CuDNN.
CUDA Installation
Check the NVIDIA guides for instructions on setting up CUDA on the NVIDIA website.
Troubleshooting
Nd4jBackend$NoAvailableBackendException
There are multiple reasons why you might run into this error message.
You haven't configured an ND4J backend at all.
You have a jar file that doesn't contain a backend for your platform.
You have a jar file that doesn't contain service loader files.
You haven't configured any ND4J Backend
Read this page and add a ND4J Backend to your dependencies:
You have a jar file that doesn't contain a backend for your platform.
This happens when you use a non -platform
type backend dependency definition. In this case, only the Backend for the system that the jar file was built on will be included.
To solve this issue, use nd4j-native-platform
instead of nd4j-native
, if you are running on CPU and nd4j-cuda-10.2-platform
instead of nd4j-cuda-10.2
when using the GPU backend.
If the jar file only contains the GPU backend, but your system has no CUDA capable (CC >= 3.5) GPU or CUDA isn't installed on the system, the CPU Backend should be used instead.
You have a jar file that doesn't contain service loader files.
ND4J uses the Java ServiceLoader in order to detect which backends are available on the class path. Depending on your uberjar packaging configuration, those files might be stripped away or broken.
To double check that the required files are included, open your uberjar and make sure it contains /META-INF/services/org.nd4j.linalg.factory.Nd4jBackend
. Then open the file, and make sure there are entries for all of your configured backends.
If your uberjar does not contain that file, or if not all of the configured backends are listed there, you will have to reconfigure your shade plugin. See ServicesResourceTransformer documentation for how to do that.
Last updated