To save a video of a rollout when running rllib locally, I’ve added
--video-dir outputs to the argument of rollout.py, so it goes into the
if video_dir: condition of rollouts.py and creates a Monitor wrapper, and does call
render() many times, but still it doesn’t save any videos in the dir
I’ve also tried to render things directly using the Procgen Wrapper env without using ray, but it still doesn’t render, and now I’m trying to render things directly with procgen, and I’m still not succeeding (cf. my comment on the procgen repo here)
What am I missing?
Can you share the procgen version that you are using?
Note: it does save some files in
openaigym.manifest.0.27441.manifest.json), just not videos.
Note2: I’ve upgraded the procgen version to
0.10.3 and it still doesn’t save any video when adding
For procgen==0.10.x, you need to pass
render_mode="rgb_array" as a config option to the environment for the videos.
PS: Note that passing
render_mode="rgb_array" will have a performance impact and is not recommended to be used during training.
I also have the same issue. I tried env = gym.make(‘procgen:procgen-coinrun-v0’, render_mode=‘rgb_array’)
and wrap it with gym Monitor but still no video (it works with CartPole-v0 though). Anything I am missing?
Can you try the same with
Yes I am using
Do you see any warning that says something like
render() returned None when you use the Monitor wrapper?
@jyotish With render_mode=‘rgb_array’ + correct version of procgen and gym3 render returns None.
@xiaocheng_tang We might need to use gym3’s
VideoRecorderWrapper instead of a Monitor if we’re using gym3 environments, because when we pass
render_mode=‘rgb_array’ it creates some vectorized observations (different from simple gym).
I’m still a bit uncertain about if we should use gym or gym3 in the rollouts.py file. Really seems like Monitor is for old gym environments.
EDIT: more infos in the same procgen issue.
Hello @mtrazzi @xiaocheng_tang
This example should work.
env = gym.make("procgen:procgen-coinrun-v0", render_mode="rgb_array")
env.metadata["render.modes"] = ["human", "rgb_array"]
env = gym.wrappers.Monitor(env=env, directory="./videos", force=True)
episodes = 10
_ = env.reset()
done = False
while episodes > 0:
_, _, done, _ = env.step(env.action_space.sample())
_ = env.reset()
episodes -= 1
This example works, thanks!
Does it work properly for everyone else? When I run it for 100 episodes it only saves episodes number 0, 1, 8, 27, 64.