Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] Cannot render toy_text envs in Google Colab #3032

Closed
KristianHolsheimer opened this issue Aug 17, 2022 · 6 comments · Fixed by #3037
Closed

[Bug Report] Cannot render toy_text envs in Google Colab #3032

KristianHolsheimer opened this issue Aug 17, 2022 · 6 comments · Fixed by #3037

Comments

@KristianHolsheimer
Copy link
Contributor

Describe the bug

The env.render() functionality is broken for toy text envs when running in google colab.

Code example

Below is a simple example to repro this bug, see also this notebook.

%pip install 'gym==0.25.1' --quiet

import gym
print(gym.__version__)  # 0.25.1
env = gym.make('FrozenLake-v1')
env.reset()
env.render()  # error: No available video device

The error is triggered when pygame tries to initialize the (nonexistent) display:

pygame.init()          # ok
pygame.display.init()  # fail

System Info
This is running on google colab (notebook).

Additional context

It looks like the backend for toy text envs was changed to pygame. What was the reason for that change?

@RedTachyon
Copy link
Contributor

FWIW I can't access the notebook, you need to update permissions.

It looks like the backend for toy text envs was changed to pygame. What was the reason for that change?

It looks better and functions analogously to all other envs (i.e. you can render it as an image, and then record a video or something).


In any case, the old mode is available via

env = gym.make('FrozenLake-v1', render_mode="ansi"))
env.reset()
print(env.render()[0])

There is an extra hitch in the fact that the ansi mode returns a list of renders, but it should work without any rendering devices.

@pseudo-rnd-thoughts
Copy link
Contributor

I suspect that rendering is broken for collab and jupyter notebook.
My guess is human rendering for collab will never work due to the code not running locally. As for jupyter notebook, it works, it just crashes.
@andrewtanJS is currently investigating the notebook issue

@KristianHolsheimer
Copy link
Contributor Author

Thanks, yes I looked into it a bit further this morning and looks like the general rendering API has changed.

As an end user, it's not clear what to expect from env.render() in general. It seems that it may ...

  • return values without rendering side-effects
  • return values with rendering side-effects
  • return nothing but has rendering side-effects
  • return nothing and no rendering side-effects (maybe because something failed silently)

Also, a small nit: env.render(mode='somemode') has no effect if env.render_mode is set.

@KristianHolsheimer
Copy link
Contributor Author

PS I updated the notebook, it's basically just import gym, env.reset(), env.render().

@RedTachyon
Copy link
Contributor

As an end user, it's not clear what to expect from env.render() in general.

Oh yea, that's an unfortunate artifact of the code we were left with when we restarted the maintenance. It's the reason why the render API is undergoing major changes, one of which is the whole env.render_mode thing.

In a future release, you won't be calling env.render(mode='somemode'), currently it's only kept for backwards compatibility. Instead, you just set the render mode on initialization, and call env.render().

I'm afraid we don't have a clear plan at the moment to properly make it make sense, because the output of env.render() will still depend on the render mode. And we can't easily just rip it out and rewrite in a more sane way, because it's very ingrained in many codebases already.

@jkterry1
Copy link
Collaborator

Closing in favor of PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants