question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

evn.render() in doc examples don't run unless n_envs=1 in make_vec_env()

See original GitHub issue

This is possibly quite trivial, but the evn.render() lines of the code examples do not run for multiprocess environments unless unless n_envs=1 in make_vec_env().

For example, the code example on this page

I’m using stable-baselines 2.10.0.

The error is

Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
  File "/lib/python3.6/site-packages/stable_baselines/common/vec_env/dummy_vec_env.py", line 85, in render
    return super().render(*args, **kwargs)
TypeError: render() missing 1 required positional argument: 'mode'

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
araffincommented, Jul 14, 2020

@Miffyli what version are you using?

The following code works for me (using latest master version):

from stable_baselines.common.cmd_util import make_vec_env

n_envs = 4
env = make_vec_env('CartPole-v1', n_envs=n_envs)
 
obs = env.reset()
for _ in range(100):
    env.step([env.action_space.sample() for _ in range(n_envs)])
    env.render()

(it works also with SB3)

0reactions
pstansellcommented, Jul 14, 2020

Thanks for the amazingly quick resolution!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Environment working, but not render() · Issue #762 · openai/gym
When I run the below code, I can execute steps in the environment ... import gym env = gym.make('CartPole-v0') env.reset() env.render() for ...
Read more >
Vectorized Environments - Stable Baselines - Read the Docs
Gym environment rendering. If there are multiple environments then they are tiled together in one image via BaseVecEnv.render() .
Read more >
Custom Environments in OpenAI's Gym | Towards Data Science
Beginner's guide on how to set up, verify, and use a custom environment in reinforcement learning training with Python.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found