Ecosystem Overview
Overview of the Eclipse Deeplearning4j ecosystem — ND4J, DL4J, DataVec, SameDiff, Python4J, and OmniHub
Eclipse Deeplearning4j is a suite of JVM-based libraries for building, training, and deploying deep learning models. The project is hosted as a single monorepo on GitHub and ships six user-facing libraries that cover every stage of a machine learning project — from raw data ingestion to distributed training and production serving.
DL4J runs on Java 11 and later. It targets x86_64 (with AVX2 and AVX512 acceleration), ARM (AArch64), and PowerPC (PPC64LE) CPUs, as well as NVIDIA GPUs through a CUDA backend. Windows, Linux, and macOS are all first-class platforms.
The Library Stack
The six libraries are layered. Lower layers provide the compute substrate; upper layers provide higher-level abstractions. Understanding the boundaries between layers prevents confusion when debugging dependency issues or choosing which API to use.
libnd4j (C++)
libnd4j is the native C++ foundation. It provides hand-tuned kernel implementations for tensor operations — element-wise math, BLAS routines, convolutions, reductions, random number generation — compiled separately for each target platform. The x86 builds use AVX2 or AVX512 intrinsics; the CUDA build links against cuBLAS and cuDNN.
Users never import libnd4j directly. It is bundled inside the platform-specific JAR artifacts for ND4J. Its existence matters when diagnosing native crashes or when building from source for a custom platform.
ND4J (Java)
ND4J is the tensor library for the JVM, analogous in purpose to NumPy. Every numerical operation in the DL4J ecosystem flows through ND4J.
The central abstraction is INDArray — an n-dimensional array that may live in CPU RAM or GPU VRAM depending on the active backend. The Nd4j factory class creates arrays:
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.factory.Nd4j;
// Create a 3x4 matrix of zeros
INDArray zeros = Nd4j.zeros(3, 4);
// Create from Java array
INDArray a = Nd4j.create(new float[]{1, 2, 3, 4, 5, 6}, new int[]{2, 3});
// Element-wise multiply
INDArray b = Nd4j.ones(2, 3);
INDArray c = a.mul(b);
// Matrix multiply
INDArray result = a.mmul(b.transpose()); // shape [2, 2]ND4J also ships activations (Nd4j.getActivations()), loss functions (LossFunctions), updaters (Adam, SGD, RMSProp), and evaluation classes (Evaluation, RegressionEvaluation).
The backend is pluggable at the dependency level. Swap nd4j-native for nd4j-cuda and the same Java code executes on GPU — no source changes required.
SameDiff (inside ND4J)
SameDiff is ND4J's automatic differentiation framework. It lives in the nd4j-api module alongside the INDArray API. SameDiff lets you define computation graphs symbolically using SDVariable nodes, execute them with concrete data, and differentiate through them automatically.
SameDiff can import pre-trained TensorFlow SavedModel and frozen graph files, as well as ONNX models, making it the primary entry point for running Python-trained models inside the JVM without a Python runtime.
DataVec
DataVec is the data ETL (extract, transform, load) library. Raw data in CSV, image directories, JSON, sequence files, JDBC, or dozens of other formats flows in through a RecordReader and comes out as DataSet objects ready for training.
The two core components are:
RecordReader — reads raw bytes and emits
List<Writable>records. Implementations includeCSVRecordReader,ImageRecordReader,JDBCRecordReader, and many others.TransformProcess — a chainable pipeline that maps, filters, normalizes, and reorders records according to a declared
Schema.
DataVec pipelines run locally or scale out on Apache Spark with no code changes to the transform logic.
Deeplearning4j (DL4J)
DL4J is the high-level neural network API. It sits on top of ND4J and DataVec and provides two model types:
MultiLayerNetwork— a sequential stack of layers, suitable for feedforward, convolutional, and recurrent networks.ComputationGraph— a directed acyclic graph of layers, required for multi-input/multi-output architectures, skip connections (ResNet), and any topology thatMultiLayerNetworkcannot express.
DL4J also includes:
NLP utilities — Word2Vec, Doc2Vec, GloVe, and tokenizers.
Model Zoo — pretrained weights for VGG16, ResNet50, YOLO, InceptionV3, and others via the
deeplearning4j-zoomodule.Distributed training — gradient sharing and parameter averaging on Apache Spark clusters via
deeplearning4j-scaleout-spark.Training UI — a local web server (port 9000 by default) that streams loss curves and weight histograms to a browser during training.
Python4J
Python4J embeds CPython 3.10 into the JVM via JavaCPP-packaged binaries. This allows Java code to call Python functions, execute scripts, and pass data between the two runtimes without serialization overhead.
The python4j-numpy extension provides zero-copy interop between INDArray and numpy.ndarray by sharing the underlying memory buffer:
Python4J is useful for calling scipy routines, custom preprocessing logic, or model inference libraries that do not yet have a JVM equivalent.
OmniHub
OmniHub is a model hub for the DL4J ecosystem. It provides a registry of pretrained models in DL4J (MultiLayerNetwork/ComputationGraph) and SameDiff formats, downloadable with a single API call:
OmniHub handles checksum verification, caching to ~/.deeplearning4j/models/, and version resolution.
Dependency Diagram
DataVec, DL4J, Python4J, and OmniHub all declare a dependency on nd4j-api. Your application must supply exactly one backend implementation (nd4j-native or nd4j-cuda) on the classpath at runtime.
Typical Workflow
A complete DL4J project follows this path:
Raw data (CSV files, image folders, database tables) is pointed to by a
RecordReader.DataVec applies a
TransformProcessto clean, type-cast, and normalize the records.A
DataSetIterator(usuallyRecordReaderDataSetIterator) wraps the reader and batches records intoDataSetobjects.DL4J trains a
MultiLayerNetworkorComputationGraphby iterating over theDataSetIterator.An
Evaluationobject scores the model on a held-out test iterator.ModelSerializer.writeModel()saves the trained model and normalizer to disk.At inference time,
ModelSerializer.restoreMultiLayerNetwork()reloads the model, which can then score newINDArrayinputs directly.
Maven Setup for M2.1
Add the version property and the two core dependencies to your pom.xml:
deeplearning4j-core is a convenience aggregate that pulls in deeplearning4j-nn (the layer and model classes) and nd4j-api (the INDArray interface and SameDiff). It does not pull in a backend — that is always your choice.
For DataVec, add:
Add format-specific modules as needed — for example datavec-data-image for ImageRecordReader, or datavec-data-codec for video.
Backend Selection
Platform artifacts vs. classifier-specific artifacts
The -platform suffix (nd4j-native-platform, nd4j-cuda-platform) causes Maven to download native JARs for all supported OS and architecture combinations. This is the recommended approach during development because it produces a portable artifact — the same JAR runs on any developer machine regardless of OS or CPU brand.
In production, where the target hardware is known, use classifier-specific artifacts to avoid shipping unnecessary natives. For example, to target Linux on x86_64 with AVX2:
Switching to GPU
Replace nd4j-native-platform with nd4j-cuda-platform. No Java source code changes are required:
The CUDA version suffix (11.6) must match the CUDA toolkit installed on the machine. At runtime ND4J detects available GPUs through JavaCPP's CUDA bindings and allocates device memory automatically. You can control device selection with Nd4j.getAffinityManager().
Only one backend may be active per JVM process. If both nd4j-native and nd4j-cuda appear on the classpath, nd4j-cuda wins by default; set the system property -Dorg.nd4j.linalg.factoryclass=org.nd4j.linalg.cpu.nativecpu.CpuNDArrayFactory to force CPU.
Where to Go Next
With the ecosystem map in mind, the remaining core-concepts pages cover each layer in depth:
INDArray and ND4J Operations — shapes, strides, views, broadcasting rules, and the full operation API.
SameDiff and Automatic Differentiation — defining graphs, custom ops, and importing TensorFlow/ONNX models.
DataVec ETL Pipelines — schemas, all built-in
RecordReaderimplementations,TransformProcessin detail, and Spark execution.MultiLayerNetwork and ComputationGraph — layer catalog, configuration options, training callbacks, and the training UI.
Backend Configuration — memory management, workspace configuration, cuDNN integration, and profiling native performance.
Last updated
Was this helpful?