I am using RL4J QLearning and i constantly get an out of memory error. This is what my QLearning Configuration looks like, the memory leak doesn’t come from my application, I’ve tried giving it a ton of memory, tried WorkspaceConfigurations and yeah now I ran out of ideas:
public static QLearning.QLConfiguration TETRIS_QL =
new QLearning.QLConfiguration(
123, //Random seed
10000, //Max step By epoch
50000000, //Max step
5000, //Max size of experience replay
32, //size of batches
20, //target update (hard)
10, //num step noop warmup
0.1, //reward scaling
0.99, //gamma
1.0, //td-error clipping
0.1f, //min epsilon
1000, //num step for eps greedy anneal
false //double DQN
);
Exception in thread "main" java.lang.OutOfMemoryError: Cannot allocate new DoublePointer(14): totalBytes = 837K, physicalBytes = 8224M
at org.bytedeco.javacpp.DoublePointer.<init>(DoublePointer.java:76)
at org.nd4j.linalg.api.buffer.BaseDataBuffer.<init>(BaseDataBuffer.java:705)
at org.nd4j.linalg.api.buffer.DoubleBuffer.<init>(DoubleBuffer.java:48)
at org.nd4j.linalg.api.buffer.factory.DefaultDataBufferFactory.create(DefaultDataBufferFactory.java:288)
at org.nd4j.linalg.factory.Nd4j.getDataBuffer(Nd4j.java:1492)
at org.nd4j.linalg.factory.Nd4j.createTypedBuffer(Nd4j.java:1502)
at org.nd4j.linalg.cpu.nativecpu.CpuNDArrayFactory.create(CpuNDArrayFactory.java:344)
at org.nd4j.linalg.factory.BaseNDArrayFactory.create(BaseNDArrayFactory.java:1350)
at org.nd4j.linalg.factory.Nd4j.create(Nd4j.java:3547)
at org.nd4j.linalg.factory.Nd4j.create(Nd4j.java:3391)
at org.deeplearning4j.rl4j.util.LegacyMDPWrapper.getInput(LegacyMDPWrapper.java:106)
at org.deeplearning4j.rl4j.util.LegacyMDPWrapper.step(LegacyMDPWrapper.java:68)
at org.deeplearning4j.rl4j.learning.sync.qlearning.discrete.QLearningDiscrete.trainStep(QLearningDiscrete.java:146)
at org.deeplearning4j.rl4j.learning.sync.qlearning.QLearning.trainEpoch(QLearning.java:124)
at org.deeplearning4j.rl4j.learning.sync.SyncLearning.train(SyncLearning.java:96)
at tetris.TetrisWindow.train(TetrisWindow.java:174)
at tetris.TetrisWindow.init(TetrisWindow.java:101)
at tetris.TetrisWindow.run(TetrisWindow.java:60)
at tetris.TetrisWindow.<init>(TetrisWindow.java:56)
at tetris.TetrisWindow.main(TetrisWindow.java:52)
Caused by: java.lang.OutOfMemoryError: Physical memory usage is too high: physicalBytes (8224M) > maxPhysicalBytes (8192M)
at org.bytedeco.javacpp.Pointer.deallocator(Pointer.java:659)
at org.bytedeco.javacpp.Pointer.init(Pointer.java:127)
at org.bytedeco.javacpp.DoublePointer.allocateArray(Native Method)
at org.bytedeco.javacpp.DoublePointer.<init>(DoublePointer.java:68)
... 19 more