You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am a PhD student trying to use mujoco to simulate the control of a robot for reinforcement learning. I am reloading the xml string and recreating the model for every simulation run to adjust certain parameters such as body mass, joint stiffness, or damping. If the learning process is long, the code will gradually eat up all the available memory.
Here is a sample code to demonstrate the problem I ran into. If you ran the code, the memory usage (reported in the task manager) of the python process keeps increasing. An interesting observation is that if I commented out mujoco.set_mjcb_control(cb) or move callback function directly before mujoco.mj_step(model, data), the memory usage becomes stable.
What is the proper way to rerun the simulation within a python process? Or is this actually a bug?
Environment:
Windows 10
python 3.9
mujoco 2.2.2
import mujoco
import time
XML = r"""
<mujoco>
<worldbody>
<geom type="box" size="1 1 0.1"/>
<body>
<freejoint/>
<geom type="box" size="0.1 0.1 0.1" pos="0 0 1"/>
</body>
</worldbody>a
</mujoco>
"""
def cb(m, d):
pass
for i in range(100):
mujoco.set_mjcb_control(None)
model = mujoco.MjModel.from_xml_string(XML, {})
data = mujoco.MjData(model)
mujoco.set_mjcb_control(cb)
while data.time < 10:
mujoco.mj_step(model, data)
time.sleep(1)
The text was updated successfully, but these errors were encountered:
iicfcii
changed the title
Memory usage keeps increasing while res
Memory usage keeps increasing while resetting and running the simulation multiple times
Oct 12, 2022
iicfcii
changed the title
Memory usage keeps increasing while resetting and running the simulation multiple times
Memory usage keeps increasing while rerunning the simulation multiple times
Oct 12, 2022
I'm able to repro the memory footprint increase, however if I add gc.collect() immediately after the inner loop (i.e. where you currently have time.sleep(1) now) the memory usage no longer increases.
Could you please confirm that this is what you see as well?
I am a PhD student trying to use mujoco to simulate the control of a robot for reinforcement learning. I am reloading the xml string and recreating the model for every simulation run to adjust certain parameters such as body mass, joint stiffness, or damping. If the learning process is long, the code will gradually eat up all the available memory.
Here is a sample code to demonstrate the problem I ran into. If you ran the code, the memory usage (reported in the task manager) of the python process keeps increasing. An interesting observation is that if I commented out
mujoco.set_mjcb_control(cb)
or move callback function directly beforemujoco.mj_step(model, data)
, the memory usage becomes stable.What is the proper way to rerun the simulation within a python process? Or is this actually a bug?
Environment:
Windows 10
python 3.9
mujoco 2.2.2
The text was updated successfully, but these errors were encountered: