Increasing memory usage throughout run time
See original GitHub issueDescribe the bug Ever increasing memory usage while running. Each process has a similar amount of usage that increases linearly with the time it runs for. Eventually resulting in slow performance or system instability on long runs.
Code example
import gym
from stable_baselines.common.policies import MlpPolicy
from stable_baselines.common.vec_env import SubprocVecEnv
from stable_baselines import A2C
n_cpu = 8
env = SubprocVecEnv([lambda: gym.make('CartPole-v1') for _ in range(n_cpu)])
model = A2C(MlpPolicy, env)
model.learn(total_timesteps=int(1e10))
This appears to be the minimal code needed to view the memory issues. It becomes more obvious if you increase the number of processes, or in larger environments.
Initially ran on some custom environments from https://github.com/rubenrtorrado/GVGAI_GYM and also tried it with DQN or a CnnPolicy both of which still had this problem.
System Info Describe the characteristic of your environment:
- Tried on a Ubuntu Desktop and a MacBook Pro
- Library installed via pip (tensorflow too)
- GTX 1080 for Desktop, None in Laptop
- Python 3.6.8
- Tensorflow 1.12.0 (gpu version for desktop)
Issue Analytics
- State:
- Created 5 years ago
- Comments:7
Top Results From Across the Web
Fix High RAM Memory Usage Issue on Windows 11/10 [10 ...
1. Close Unnecessary Running Programs/Applications; 2. Disable Startup Programs; 3. Defragment Hard Drive & Adjust Best Performance; 4. Fix Disk ...
Read more >Why does process memory usage increase in runtime? - Quora
If the RAM memory demands of a process continually increase over the runtime of a program your program most likely has a memory...
Read more >Windows 10 High Memory Usage [Causes and Solutions]
Fix 1: Close unnecessary programs. If the high memory usage is caused by the computer running multiple programs at the same time, users...
Read more >High Memory utilization and their root causes | Dynatrace
Increasing memory is the obvious workaround for memory leaks or badly written software. Let's discuss the two most common causes for Java high...
Read more >Why does my App's Memory Use Grow Over Time? - Schneems
It takes a while, but over time, memory use doubles. The height of thread one and two roughly max out at about 390...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have also encountered this issue, as has someone else on the openai repo, https://github.com/openai/baselines/issues/804.
I have determined this to be a bug with the latest version of
numpy
, in particular1.16.0
. Downgrading tonumpy==1.15.4
fixed the issue for me.Below is a minimal, complete, and verifiable example of the bug:
On
numpy==1.16.0
this will quickly OOM, on1.15.4
it is fine. In their release notes they said they changed to a different pickling protocol, which I guess is the source of the bug.edit: https://github.com/numpy/numpy/issues/12896
@hill-a @Kuldr Confirmed
numpy 1.16.1
fixes the issue