deeplearning4j icon indicating copy to clipboard operation
deeplearning4j copied to clipboard

Possible inefficient Memory usage

Open Flips01 opened this issue 7 years ago • 1 comments

I am using DL4J 1.0.0-beta3 with CUDA 10.0 on Ubuntu 18.04.

I have noticed that there is an issue with memory consumption when you fit a NormalizerStandardize and directly afterwards use it to fit your net. Such an implementation uses ~3147MiB of memory on my GPU. Once I don't fit the normalizer but load a serialized version the memory consumption drops drastically to ~1575MiB.

Pseudocode of the issue. The first run would consume ~3147MiB of memory, the second ~1575MiB:

DataSetIterator trainData = new SequenceRecordReaderDataSetIterator();
DataNormalization normalizer;
if(serializedNormalizer.exists()) {
   normalizer = NormalizerSerializer.getDefault().restore(serializedNormalizer);
} else {
   normalizer = new NormalizerStandardize();
   normalizer.fit(trainData);
   trainData.reset();
   NormalizerSerializer.getDefault().write(normalizer, serializedNormalizer);
}

DataSetIterator testData = new SequenceRecordReaderDataSetIterator();
trainData.setPreProcessor(normalizer);
testData.setPreProcessor(normalizer);

MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().build();
MultiLayerNetwork net = new MultiLayerNetwork(conf);
net.init();

for (int i = 0; i < 1000; i++) {
   net.fit(trainData);
   net.evaluate(testData);
}

Aha! Link: https://skymindai.aha.io/features/DL4J-3

Flips01 avatar Mar 12 '19 11:03 Flips01

Closing — this issue is over 7 years old with no recent activity. The codebase has undergone a major rewrite. If this is still relevant, please open a new issue with current reproduction steps.

agibsonccc avatar Jun 15 '26 01:06 agibsonccc