stanfordnmbl / osim-rl

Reinforcement learning environments with musculoskeletal models
http://osim-rl.stanford.edu/
MIT License
894 stars 249 forks source link

memory leak problem #132

Closed ghost closed 6 years ago

ghost commented 6 years ago

following the instruction of README.md, I found that memory usage keep rising, just like that in nips2017 #10 Here is my code and output: memory.py

#-*- coding: utf-8 -*-
#File: memory.py
from osim.env import ProstheticsEnv 
import numpy as np
import argparse
import os
import psutil
env = ProstheticsEnv(visualize=False)
env.change_model(model='3D', difficulty=0, prosthetic=True)
def append(current_obs, obs):
  if not isinstance(obs, list):
    obs = [obs]
  return current_obs + obs

process = psutil.Process(os.getpid())
step = 0
def detect_memory():
  global step
  step += 1
  return process.memory_info().rss

def play_one_episode():
    global env, algorithm
    observation = env.reset(project=False)
    all_reward = 0
    for i in range(400):
        detect_memory()
        observation, reward, done, info = env.step(env.action_space.sample(), project=False)
        all_reward += reward
        if done:
            break
    return all_reward

if __name__ == '__main__':
  mean_reward = []
  for e in range(10000000):
      e_reward = play_one_episode()
      mean_reward.append(e_reward)
      print("episode:{}  step:{}   memory_uasge:{}".format(e, step, process.memory_info().rss))
  mean_reward = np.mean(mean_reward)

output memory info

episode:0  step:99   memory_uasge:142286848
episode:1  step:199   memory_uasge:142815232
episode:2  step:299   memory_uasge:143896576
episode:3  step:401   memory_uasge:144166912
episode:4  step:500   memory_uasge:147410944
episode:5  step:602   memory_uasge:147410944
episode:6  step:703   memory_uasge:147410944
episode:7  step:803   memory_uasge:147410944
episode:8  step:902   memory_uasge:147410944
episode:9  step:1002   memory_uasge:153088000
episode:10  step:1102   memory_uasge:153088000
episode:11  step:1202   memory_uasge:153088000
episode:12  step:1304   memory_uasge:153088000
episode:13  step:1404   memory_uasge:153088000
episode:14  step:1505   memory_uasge:153088000
episode:15  step:1605   memory_uasge:153088000
episode:16  step:1707   memory_uasge:153088000
episode:17  step:1808   memory_uasge:153088000
episode:18  step:1908   memory_uasge:153088000
episode:19  step:2008   memory_uasge:165253120
episode:20  step:2108   memory_uasge:165253120
episode:21  step:2208   memory_uasge:165253120
ghost commented 6 years ago

here is my anaconda environment information

# packages in environment at /home/robot/anaconda2/envs/opensim3:
#
# Name                    Version                   Build  Channel
_tflow_180_select         1.0                         gpu    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
absl-py                   0.2.2                    py36_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
astor                     0.6.2                    py36_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
backports                 1.0              py36hfa02d7e_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
backports.weakref         1.0rc1                   py36_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
blas                      1.0                         mkl    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
bleach                    1.5.0                    py36_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
ca-certificates           2018.03.07                    0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
certifi                   2018.4.16                py36_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
cffi                      1.11.5                    <pip>
chardet                   3.0.4                     <pip>
cudatoolkit               9.0                  h13b8566_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
cudnn                     7.1.2                 cuda9.0_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
cupti                     9.0.176                       0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
curl                      7.60.0                        0    conda-forge
Cython                    0.28.3                    <pip>
expat                     2.2.5                         0    conda-forge
freeglut                  3.0.0                         4    kidzik
future                    0.16.0                    <pip>
gast                      0.2.0                    py36_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
git                       2.17.1                        0    conda-forge
glfw                      1.6.0                     <pip>
grpcio                    1.12.1           py36hdbcaa40_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
gym                       0.9.0                     <pip>
html5lib                  0.9999999                py36_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
idna                      2.6                       <pip>
imageio                   2.3.0                     <pip>
intel-openmp              2018.0.3                      0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
krb5                      1.14.6                        0    conda-forge
lapack                    3.6.1                         1    conda-forge
libgcc-ng                 7.2.0                hdf63c60_3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libgfortran               3.0.0                         1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
libgfortran-ng            7.2.0                hdf63c60_3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libiconv                  1.15                          0    conda-forge
libprotobuf               3.5.2                h6f1eeef_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libssh2                   1.8.0                         2    conda-forge
libstdcxx-ng              7.2.0                hdf63c60_3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
markdown                  2.6.11                   py36_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl                       2018.0.3                      1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl_fft                   1.0.1            py36h3010b51_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl_random                1.0.1            py36h629b387_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mujoco-py                 0.5.7                     <pip>
numpy                     1.14.3                    <pip>
numpy                     1.14.5           py36hcd700cb_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
numpy-base                1.14.5           py36hdbf6ddf_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
openblas                  0.2.19                        0    kidzik
opensim                   4.0.0                   py36_17    kidzik
openssl                   1.0.2o               h20670df_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
osim-rl                   2.0.0                     <pip>
Pillow                    5.1.0                     <pip>
pip                       10.0.1                   py36_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
protobuf                  3.5.2            py36hf484d3e_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
psutil                    5.4.6                     <pip>
pyarrow                   0.9.0                     <pip>
pycparser                 2.18                      <pip>
pyglet                    1.3.2                     <pip>
PyOpenGL                  3.1.0                     <pip>
python                    3.6.1                         2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
pyzmq                     17.0.0                    <pip>
readline                  6.2                           2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
redis                     2.10.6                    <pip>
requests                  2.18.4                    <pip>
scikit-learn              0.19.1                    <pip>
scipy                     1.1.0                     <pip>
setuptools                39.2.0                   py36_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
six                       1.11.0                    <pip>
six                       1.11.0           py36h372c433_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
sqlite                    3.13.0                        0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
tabulate                  0.8.2                     <pip>
tensorboard               1.7.0            py36hf484d3e_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
tensorflow                1.2.1                    py36_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
tensorflow-base           1.8.0            py36hc1a7637_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
tensorflow-gpu            1.7.0                         0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
tensorflow-gpu-base       1.7.0            py36hcdda91b_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
tensorpack                0.8.6                     <pip>
termcolor                 1.1.0                    py36_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
termcolor                 1.1.0                     <pip>
timeout-decorator         0.4.0                     <pip>
tk                        8.5.18                        0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
tqdm                      4.23.4                    <pip>
urllib3                   1.22                      <pip>
werkzeug                  0.14.1                   py36_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
wheel                     0.31.1                   py36_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
xz                        5.2.4                h14c3975_4    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
zlib                      1.2.11               ha838bed_2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main

system info:

$: cat /etc/issue
Ubuntu 16.04 LTS \n \l
ghost commented 6 years ago

solved by using hack #58