openai / gym

A toolkit for developing and comparing reinforcement learning algorithms.
https://www.gymlibrary.dev
Other
34.8k stars 8.61k forks source link

env.render() display error #735

Closed BIGBALLON closed 6 years ago

BIGBALLON commented 7 years ago

When I use SSH to connect remote server. env.render() makes the following errors:

> python3 tt.py [2017-09-28 05:16:23,105] Making new env: CartPole-v0 Traceback (most recent call last): File "tt.py", line 5, in <module> env.render() File "/usr/local/lib/python3.5/dist-packages/gym/core.py", line 150, in render return self._render(mode=mode, close=close) File "/usr/local/lib/python3.5/dist-packages/gym/core.py", line 286, in _render return self.env.render(mode, close) File "/usr/local/lib/python3.5/dist-packages/gym/core.py", line 150, in render return self._render(mode=mode, close=close) File "/usr/local/lib/python3.5/dist-packages/gym/envs/classic_control/cartpole.py", line 115, in _render from gym.envs.classic_control import rendering File "/usr/local/lib/python3.5/dist-packages/gym/envs/classic_control/rendering.py", line 23, in <module> from pyglet.gl import * File "/usr/local/lib/python3.5/dist-packages/pyglet/gl/__init__.py", line 236, in <module> import pyglet.window File "/usr/local/lib/python3.5/dist-packages/pyglet/window/__init__.py", line 1816, in <module> gl._create_shadow_window() File "/usr/local/lib/python3.5/dist-packages/pyglet/gl/__init__.py", line 205, in _create_shadow_window _shadow_window = Window(width=1, height=1, visible=False) File "/usr/local/lib/python3.5/dist-packages/pyglet/window/xlib/__init__.py", line 163, in __init__ super(XlibWindow, self).__init__(*args, **kwargs) File "/usr/local/lib/python3.5/dist-packages/pyglet/window/__init__.py", line 493, in __init__ display = get_platform().get_default_display() File "/usr/local/lib/python3.5/dist-packages/pyglet/window/__init__.py", line 1765, in get_default_display return pyglet.canvas.get_display() File "/usr/local/lib/python3.5/dist-packages/pyglet/canvas/__init__.py", line 82, in get_display return Display() File "/usr/local/lib/python3.5/dist-packages/pyglet/canvas/xlib.py", line 83, in __init__ raise NoSuchDisplayException('Cannot connect to "%s"' % name) pyglet.canvas.xlib.NoSuchDisplayException: Cannot connect to "None"

I tried all of the following methods, but it still not work.

https://github.com/openai/gym/issues/637 https://github.com/openai/universe/issues/91

Can someone help me ?

YLili commented 7 years ago

I have the same problem. Have you solved it?

BIGBALLON commented 7 years ago

Yeah. I solved it by using fake screen

See this for details.

https://github.com/2017-fall-DL-training-program/Setup_tutorial/blob/master/OpenAI-gym-install.md

YLili commented 7 years ago

Thank you very much! @BIGBALLON

jamsawamsa commented 6 years ago

So I've been following the installation procedure as mentioned above on https://github.com/2017-fall-DL-training-program/Setup_tutorial/blob/master/OpenAI-gym-install.md

But I keep getting the following issues when I run anydesk:

No UTF-8. Trying to change locale.
Locale sucessfully changed.
No protocol specified

(anydesk:11313): Gtk-WARNING **: cannot open display: :0
No UTF-8. Trying to change locale.
Locale sucessfully changed.
No protocol specified

(anydesk:11315): Gtk-WARNING **: cannot open display: :0
No protocol specified

Did you guys have to deal with this too?

boranzhao commented 6 years ago

@jamsawamsa I met the same problem. Have you solved your problem?

boranzhao commented 6 years ago

@jamsawamsa I found a way to solve the "No protocol specified" problem. First, make sure to use an SSH client to support x11 forwarding, e.g. Putty. It seems that OpenSSH does not. Then follow the steps here https://unix.stackexchange.com/a/12772/294158 to set up x11 forwarding. Third, install Xming and keep it running when using SSH to connect to the server.

However, the render problem mentioned by @BIGBALLON still remained. I finally solved the render problem by following the steps here.

.