Open nimishjain15882 opened 3 years ago
I have pasted logs for Ubuntu 20.04 above for now. But I face same issue in Windows as well. Probably if Ubuntu is fixed, Windows will work as well.
@nimishjain15882 could you set MXNET_GPU_MEM_POOL_RESERVE to 10 or 20? MXNET_GPU_MEM_POOL_RESERVE is used to tell MXNet how much memory we want to reserve for cuda kernel launch and cudnn handle space, which in this case might resolve CUDNN_STATUS_EXECUTION_FAILED
assign it to me
I can confirm that:
The latest master version (8ee0b8b) works with no issue and no changes on Ubuntu with a RTX 2080 TI (11GB) with a memory usage of 5% and GPU of arround 60%. Tested removing the FPS limitation.
On windows there is a memory leak. OOM before hitting 15,000 iterations. The GPU usage is reported at 16%, the RAM consumption increases no matter what changes to the code are done:
This points to an issue on the backend native implementations rather than:
Things to try:
Description
I tried running https://github.com/kingyuluk/RL-FlappyBird/ on Windows & Ubuntu. However, after sometime both throw Out Of Memory Error during training. Ruducing batch size doesn't help either. It appears there is a memory leak.
Expected Behavior
The training should continue.
Error Message
[pool-1-thread-2] ERROR ai.djl.ndarray.BaseNDManager - Resource close failed. [main] ERROR com.kingyu.rlbird.ai.TrainBird - java.util.concurrent.ExecutionException: ai.djl.engine.EngineException: MXNet engine call failed: cuDNN: Check failed: e == CUDNN_STATUS_SUCCESS (8 vs. 0) : CUDNN_STATUS_EXECUTION_FAILED Stack trace: File "src/operator/nn/./cudnn/cudnn_convolution-inl.h", line 155
at java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.util.concurrent.FutureTask.get(FutureTask.java:192) at com.kingyu.rlbird.ai.TrainBird.train(TrainBird.java:113) at com.kingyu.rlbird.ai.TrainBird.main(TrainBird.java:65)
Caused by: ai.djl.engine.EngineException: MXNet engine call failed: cuDNN: Check failed: e == CUDNN_STATUS_SUCCESS (8 vs. 0) : CUDNN_STATUS_EXECUTION_FAILED Stack trace: File "src/operator/nn/./cudnn/cudnn_convolution-inl.h", line 155
at ai.djl.mxnet.jna.JnaUtils.checkCall(JnaUtils.java:1808) at ai.djl.mxnet.jna.JnaUtils.waitToRead(JnaUtils.java:459) at ai.djl.mxnet.engine.MxNDArray.close(MxNDArray.java:1549) at ai.djl.mxnet.engine.MxNDArrayIndexer.get(MxNDArrayIndexer.java:52) at ai.djl.ndarray.index.NDArrayIndexer.get(NDArrayIndexer.java:73) at ai.djl.ndarray.NDArray.get(NDArray.java:498) at ai.djl.ndarray.NDArray.get(NDArray.java:522) at com.kingyu.rlbird.rl.agent.QAgent.chooseAction(QAgent.java:58) at com.kingyu.rlbird.rl.agent.EpsilonGreedy.chooseAction(EpsilonGreedy.java:48) at com.kingyu.rlbird.game.FlappyBird.runEnvironment(FlappyBird.java:104) at com.kingyu.rlbird.ai.TrainBird$GeneratorCallable.call(TrainBird.java:174) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
ai.djl.engine.EngineException: MXNet engine call failed: MXNetError: cudaMalloc retry failed: out of memory Stack trace: File "src/storage/./pooled_storage_manager.h", line 161
at ai.djl.mxnet.jna.JnaUtils.checkCall(JnaUtils.java:1808) at ai.djl.mxnet.jna.JnaUtils.waitToRead(JnaUtils.java:459) at ai.djl.mxnet.engine.MxNDArray.close(MxNDArray.java:1549) at ai.djl.ndarray.BaseNDManager.close(BaseNDManager.java:108) at ai.djl.mxnet.engine.MxParameterServer$OptimizerCallback.apply(MxParameterServer.java:105) at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback(CallbackReference.java:520) at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback(CallbackReference.java:551) at com.sun.jna.Native.invokeInt(Native Method) at com.sun.jna.Function.invoke(Function.java:426) at com.sun.jna.Function.invoke(Function.java:361) at com.sun.jna.Library$Handler.invoke(Library.java:265) at com.sun.proxy.$Proxy1.MXKVStorePushPullEx(Unknown Source) at ai.djl.mxnet.jna.JnaUtils.parameterStorePushPull(JnaUtils.java:734) at ai.djl.mxnet.engine.MxParameterServer.update(MxParameterServer.java:63) at ai.djl.training.ParameterServer.update(ParameterServer.java:38) at ai.djl.training.ParameterStore.updateAllParameters(ParameterStore.java:74) at ai.djl.training.Trainer.step(Trainer.java:190) at com.kingyu.rlbird.rl.agent.QAgent.trainBatch(QAgent.java:118) at com.kingyu.rlbird.rl.agent.EpsilonGreedy.trainBatch(EpsilonGreedy.java:56) at com.kingyu.rlbird.ai.TrainBird$TrainerCallable.call(TrainBird.java:149) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
[pool-1-thread-2] ERROR ai.djl.ndarray.BaseNDManager - Resource close failed. ai.djl.engine.EngineException: MXNet engine call failed: MXNetError: cudaMalloc retry failed: out of memory Stack trace: File "src/storage/./pooled_storage_manager.h", line 161
at ai.djl.mxnet.jna.JnaUtils.checkCall(JnaUtils.java:1808) at ai.djl.mxnet.jna.JnaUtils.waitToRead(JnaUtils.java:459) at ai.djl.mxnet.engine.MxNDArray.close(MxNDArray.java:1549) at ai.djl.ndarray.BaseNDManager.close(BaseNDManager.java:108) at ai.djl.mxnet.engine.MxParameterServer$OptimizerCallback.apply(MxParameterServer.java:105) at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback(CallbackReference.java:520) at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback(CallbackReference.java:551) at com.sun.jna.Native.invokeInt(Native Method) at com.sun.jna.Function.invoke(Function.java:426) at com.sun.jna.Function.invoke(Function.java:361) at com.sun.jna.Library$Handler.invoke(Library.java:265) at com.sun.proxy.$Proxy1.MXKVStorePushPullEx(Unknown Source) at ai.djl.mxnet.jna.JnaUtils.parameterStorePushPull(JnaUtils.java:734) at ai.djl.mxnet.engine.MxParameterServer.update(MxParameterServer.java:63) at ai.djl.training.ParameterServer.update(ParameterServer.java:38) at ai.djl.training.ParameterStore.updateAllParameters(ParameterStore.java:74) at ai.djl.training.Trainer.step(Trainer.java:190) at com.kingyu.rlbird.rl.agent.QAgent.trainBatch(QAgent.java:118) at com.kingyu.rlbird.rl.agent.EpsilonGreedy.trainBatch(EpsilonGreedy.java:56) at com.kingyu.rlbird.ai.TrainBird$TrainerCallable.call(TrainBird.java:149) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
[pool-1-thread-2] ERROR ai.djl.ndarray.BaseNDManager - Resource close failed. ai.djl.engine.EngineException: MXNet engine call failed: Name: Check failed: err == cudaSuccess (2 vs. 0) : mxnet_generic_kernel ErrStr:out of memory Stack trace: File "src/operator/././../common/../operator/mxnet_op.h", line 1121
at ai.djl.mxnet.jna.JnaUtils.checkCall(JnaUtils.java:1808) at ai.djl.mxnet.jna.JnaUtils.waitToRead(JnaUtils.java:459) at ai.djl.mxnet.engine.MxNDArray.close(MxNDArray.java:1549) at ai.djl.ndarray.BaseNDManager.close(BaseNDManager.java:108) at ai.djl.mxnet.engine.MxParameterServer$OptimizerCallback.apply(MxParameterServer.java:105) at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback(CallbackReference.java:520) at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback(CallbackReference.java:551) at com.sun.jna.Native.invokeInt(Native Method) at com.sun.jna.Function.invoke(Function.java:426) at com.sun.jna.Function.invoke(Function.java:361) at com.sun.jna.Library$Handler.invoke(Library.java:265) at com.sun.proxy.$Proxy1.MXKVStorePushPullEx(Unknown Source) at ai.djl.mxnet.jna.JnaUtils.parameterStorePushPull(JnaUtils.java:734) at ai.djl.mxnet.engine.MxParameterServer.update(MxParameterServer.java:63) at ai.djl.training.ParameterServer.update(ParameterServer.java:38) at ai.djl.training.ParameterStore.updateAllParameters(ParameterStore.java:74) at ai.djl.training.Trainer.step(Trainer.java:190) at com.kingyu.rlbird.rl.agent.QAgent.trainBatch(QAgent.java:118) at com.kingyu.rlbird.rl.agent.EpsilonGreedy.trainBatch(EpsilonGreedy.java:56) at com.kingyu.rlbird.ai.TrainBird$TrainerCallable.call(TrainBird.java:149) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
[pool-1-thread-2] ERROR ai.djl.ndarray.BaseNDManager - Resource close failed. ai.djl.engine.EngineException: MXNet engine call failed: Name: Check failed: err == cudaSuccess (2 vs. 0) : mxnet_generic_kernel ErrStr:out of memory Stack trace: File "src/operator/././../common/../operator/mxnet_op.h", line 1121
at ai.djl.mxnet.jna.JnaUtils.checkCall(JnaUtils.java:1808) at ai.djl.mxnet.jna.JnaUtils.waitToRead(JnaUtils.java:459) at ai.djl.mxnet.engine.MxNDArray.close(MxNDArray.java:1549) at ai.djl.ndarray.BaseNDManager.close(BaseNDManager.java:108) at ai.djl.mxnet.engine.MxParameterServer$OptimizerCallback.apply(MxParameterServer.java:105) at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback(CallbackReference.java:520) at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback(CallbackReference.java:551) at com.sun.jna.Native.invokeInt(Native Method) at com.sun.jna.Function.invoke(Function.java:426) at com.sun.jna.Function.invoke(Function.java:361) at com.sun.jna.Library$Handler.invoke(Library.java:265) at com.sun.proxy.$Proxy1.MXKVStorePushPullEx(Unknown Source) at ai.djl.mxnet.jna.JnaUtils.parameterStorePushPull(JnaUtils.java:734) at ai.djl.mxnet.engine.MxParameterServer.update(MxParameterServer.java:63) at ai.djl.training.ParameterServer.update(ParameterServer.java:38) at ai.djl.training.ParameterStore.updateAllParameters(ParameterStore.java:74) at ai.djl.training.Trainer.step(Trainer.java:190) at com.kingyu.rlbird.rl.agent.QAgent.trainBatch(QAgent.java:118) at com.kingyu.rlbird.rl.agent.EpsilonGreedy.trainBatch(EpsilonGreedy.java:56) at com.kingyu.rlbird.ai.TrainBird$TrainerCallable.call(TrainBird.java:149) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
[pool-1-thread-2] ERROR ai.djl.ndarray.BaseNDManager - Resource close failed. ai.djl.engine.EngineException: MXNet engine call failed: Name: Check failed: err == cudaSuccess (2 vs. 0) : mxnet_generic_kernel ErrStr:out of memory Stack trace: File "src/operator/././../common/../operator/mxnet_op.h", line 1121
at ai.djl.mxnet.jna.JnaUtils.checkCall(JnaUtils.java:1808) at ai.djl.mxnet.jna.JnaUtils.waitToRead(JnaUtils.java:459) at ai.djl.mxnet.engine.MxNDArray.close(MxNDArray.java:1549) at ai.djl.ndarray.BaseNDManager.close(BaseNDManager.java:108) at ai.djl.mxnet.engine.MxParameterServer$OptimizerCallback.apply(MxParameterServer.java:105) at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback(CallbackReference.java:520) at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback(CallbackReference.java:551) at com.sun.jna.Native.invokeInt(Native Method) at com.sun.jna.Function.invoke(Function.java:426) at com.sun.jna.Function.invoke(Function.java:361) at com.sun.jna.Library$Handler.invoke(Library.java:265) at com.sun.proxy.$Proxy1.MXKVStorePushPullEx(Unknown Source) at ai.djl.mxnet.jna.JnaUtils.parameterStorePushPull(JnaUtils.java:734) at ai.djl.mxnet.engine.MxParameterServer.update(MxParameterServer.java:63) at ai.djl.training.ParameterServer.update(ParameterServer.java:38) at ai.djl.training.ParameterStore.updateAllParameters(ParameterStore.java:74) at ai.djl.training.Trainer.step(Trainer.java:190) at com.kingyu.rlbird.rl.agent.QAgent.trainBatch(QAgent.java:118) at com.kingyu.rlbird.rl.agent.EpsilonGreedy.trainBatch(EpsilonGreedy.java:56) at com.kingyu.rlbird.ai.TrainBird$TrainerCallable.call(TrainBird.java:149) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
[pool-1-thread-2] ERROR ai.djl.ndarray.BaseNDManager - Resource close failed. ai.djl.engine.EngineException: MXNet engine call failed: Name: Check failed: err == cudaSuccess (2 vs. 0) : mxnet_generic_kernel ErrStr:out of memory Stack trace: File "src/operator/././../common/../operator/mxnet_op.h", line 1121
at ai.djl.mxnet.jna.JnaUtils.checkCall(JnaUtils.java:1808) at ai.djl.mxnet.jna.JnaUtils.waitToRead(JnaUtils.java:459) at ai.djl.mxnet.engine.MxNDArray.close(MxNDArray.java:1549) at ai.djl.ndarray.BaseNDManager.close(BaseNDManager.java:108) at ai.djl.mxnet.engine.MxParameterServer$OptimizerCallback.apply(MxParameterServer.java:105) at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback(CallbackReference.java:520) at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback(CallbackReference.java:551) at com.sun.jna.Native.invokeInt(Native Method) at com.sun.jna.Function.invoke(Function.java:426) at com.sun.jna.Function.invoke(Function.java:361) at com.sun.jna.Library$Handler.invoke(Library.java:265) at com.sun.proxy.$Proxy1.MXKVStorePushPullEx(Unknown Source) at ai.djl.mxnet.jna.JnaUtils.parameterStorePushPull(JnaUtils.java:734) at ai.djl.mxnet.engine.MxParameterServer.update(MxParameterServer.java:63) at ai.djl.training.ParameterServer.update(ParameterServer.java:38) at ai.djl.training.ParameterStore.updateAllParameters(ParameterStore.java:74) at ai.djl.training.Trainer.step(Trainer.java:190) at com.kingyu.rlbird.rl.agent.QAgent.trainBatch(QAgent.java:118) at com.kingyu.rlbird.rl.agent.EpsilonGreedy.trainBatch(EpsilonGreedy.java:56) at com.kingyu.rlbird.ai.TrainBird$TrainerCallable.call(TrainBird.java:149) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
How to Reproduce?
(If you developed your own code, please provide a short script that reproduces the error. For existing examples, please provide link.)
Steps to reproduce
(Paste the commands you ran that produced the error.)
What have you tried to solve it?
Environment Info
Please run the command
./gradlew debugEnv
from the root directory of DJL (if necessary, clone DJL first). It will output information about your system, environment, and installation that can help us debug your issue. Paste the output of the command below: