How to do it...

  1. Add the required VM arguments to the Eclipse/IntelliJ IDE, as shown in the following example:
-Xms1G -Xmx6G -Dorg.bytedeco.javacpp.maxbytes=16G -Dorg.bytedeco.javacpp.maxphysicalbytes=20G

For example, in IntelliJ IDE, we can add VM arguments to the runtime configuration:

  1. Run the following command after changing the memory limits to suit your hardware (for command-line executions):
java -Xms1G -Xmx6G -Dorg.bytedeco.javacpp.maxbytes=16G -Dorg.bytedeco.javacpp.maxphysicalbytes=20G YourClassName
  1. Configure a server-style generational garbage collector for JVM:
java -XX:+UseG1GC
  1. Reduce the frequency of garbage collector calls using ND4J:
Nd4j.getMemoryManager().setAutoGcWindow(3000);
  1. Disable garbage collector calls instead of step 4:
Nd4j.getMemoryManager().togglePeriodicGc(false);

  1. Allocate memory chunks in memory-mapped files instead of RAM:
WorkspaceConfiguration memoryMap = WorkspaceConfiguration.builder()
.initialSize(2000000000)
.policyLocation(LocationPolicy.MMAP)
.build();
try (MemoryWorkspace workspace = Nd4j.getWorkspaceManager().getAndActivateWorkspace(memoryMap, "M")) {
INDArray example = Nd4j.create(10000);
}
..................Content has been hidden....................

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