Gymnasium: [Bug Report] save_video crashes for `mujoco-py`

Describe the bug

I have installed the gymnasium for mujoco and everything works fine. Although it works fine for other envs like classical control, however, as soon as I call the save_video function for a mujoco environment, my ubuntu machine crashes. My screen goes blank and i have to uninstall nvidia drivers, reboot (to get display), and install drivers again (to have nvidia-smi) to make everything back to the original configuration. the code i use is taken from #882 .

Code example

import gymnasium as gym
from gymnasium.utils.save_video import save_video

terminated = False
truncated = False

reward_eps = 0.0

env = gym.make('Ant-v3', render_mode='rgb_array_list')
env.reset()

while not (terminated or truncated):
    action = env.action_space.sample()
    observation, reward, terminated, truncated, info = env.step(action)

    reward_eps += reward

save_video(env.render(), "videos",
           fps=env.metadata['render_fps'],
           step_starting_index=0,
           episode_index=0)

env.close()

System info

gymnasium==0.28.1 was installed with pip ubuntu 20.04 python 3.9

Additional context

No response

Checklist

  • I have checked that there is no similar issue in the repo

About this issue

  • Original URL
  • State: closed
  • Created 3 months ago
  • Comments: 21 (14 by maintainers)

Most upvoted comments

@modanesh That is probably the best plan as mujoco is a maintained project while mujoco-py (v2 and v3) is not

Both save_video and RecordVideo wrapper work fine with CartPole-v1. Super confusing! For now, I decided to switch to v4 as this one doesn’t require mujoco_py and video recording works fine with that.

@pseudo-rnd-thoughts So there shouldn’t be such crashes?

@Kallinteris-Andreas rgb_array_list is a valid render mode, as make will add an intermediate wrapper that saves rgb_array such that render returns a list of frames