How to do it...

  1. Detach the INDArray data to use it across workspaces:
INDArray array = Nd4j.rand(6, 6);
INDArray mean = array.mean(1);
INDArray result = mean.detach();
  1. Remove all workspaces that were created during training/evaluation in case they are running short of RAM:
Nd4j.getWorkspaceManager().destroyAllWorkspacesForCurrentThread();
  1. Leverage an array instance from another workspace in the current workspace by calling leverageTo():
LayerWorkspaceMgr.leverageTo(ArrayType.ACTIVATIONS, myArray);
  1. Track the time spent on every iteration during training using PerformanceListener:
model.setListeners(new PerformanceListener(frequency,reportScore)); 
  1. Add the following Maven dependency for cuDNN support:
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-cuda-x.x</artifactId> //cuda version to be specified
<version>1.0.0-beta4</version>
</dependency>
  1. Configure DL4J/cuDNN to favor performance over memory:
MultiLayerNetwork config = new NeuralNetConfiguration.Builder()
.cudnnAlgoMode(ConvolutionLayer.AlgoMode.PREFER_FASTEST) //prefer performance over memory
.build();
  1. Configure ParallelWrapper to support multi-GPU training/inferences:
ParallelWrapper wrapper = new ParallelWrapper.Builder(model)
.prefetchBuffer(deviceCount)
.workers(Nd4j.getAffinityManager().getNumberOfDevices())
.trainingMode(ParallelWrapper.TrainingMode.SHARED_GRADIENTS)
.thresholdAlgorithm(new AdaptiveThresholdAlgorithm())
.build();

  1. Configure ParallelInference as follows:
ParallelInference inference = new ParallelInference.Builder(model)
.inferenceMode(InferenceMode.BATCHED)
.batchLimit(maxBatchSize)
.workers(workerCount)
.build();
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset