gym over ssh

Created on 12 Jan 2017  路  5Comments  路  Source: openai/gym

When running an environment over ssh, I have an error (it works fine when running directly on the computer). OS: Ubuntu 14.04.

env_src = make(args.env)
File "/opt/anaconda2/lib/python2.7/site-packages/gym/envs/registration.py", line 140, in make
return registry.make(id)
File "/opt/anaconda2/lib/python2.7/site-packages/gym/envs/registration.py", line 105, in make
return spec.make()
File "/opt/anaconda2/lib/python2.7/site-packages/gym/envs/registration.py", line 69, in make
cls = load(self._entry_point)
File "/opt/anaconda2/lib/python2.7/site-packages/gym/envs/registration.py", line 18, in load
result = entry_point.load(False)
File "/opt/anaconda2/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2291, in load
return self.resolve()
File "/opt/anaconda2/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2297, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/opt/anaconda2/lib/python2.7/site-packages/gym/envs/box2d/__init__.py", line 4, in
from gym.envs.box2d.car_racing import CarRacing
File "/opt/anaconda2/lib/python2.7/site-packages/gym/envs/box2d/car_racing.py", line 10, in
from gym.envs.classic_control import rendering
File "/opt/anaconda2/lib/python2.7/site-packages/gym/envs/classic_control/rendering.py", line 23, in
from pyglet.gl import *
File "/opt/anaconda2/lib/python2.7/site-packages/pyglet/gl/__init__.py", line 236, in
import pyglet.window
File "/opt/anaconda2/lib/python2.7/site-packages/pyglet/window/__init__.py", line 1817, in
gl._create_shadow_window()
File "/opt/anaconda2/lib/python2.7/site-packages/pyglet/gl/__init__.py", line 205, in _create_shadow_window
_shadow_window = Window(width=1, height=1, visible=False)
File "/opt/anaconda2/lib/python2.7/site-packages/pyglet/window/xlib/__init__.py", line 163, in __init__
super(XlibWindow, self).__init__(args, *kwargs)
File "/opt/anaconda2/lib/python2.7/site-packages/pyglet/window/__init__.py", line 516, in __init__
context = config.create_context(gl.current_context)
File "/opt/anaconda2/lib/python2.7/site-packages/pyglet/gl/xlib.py", line 186, in create_context
return XlibContextARB(self, share)
File "/opt/anaconda2/lib/python2.7/site-packages/pyglet/gl/xlib.py", line 296, in __init__
super(XlibContext13, self).__init__(config, share)
File "/opt/anaconda2/lib/python2.7/site-packages/pyglet/gl/xlib.py", line 199, in __init__
raise gl.ContextException('Could not create GL context')
pyglet.gl.ContextException: Could not create GL context

Most helpful comment

xvfb-run -s "-screen 0 1400x900x24" python <your_script.py> will create a fake X server for it. apt-get xvfb if you don't have it.

It would be better if import pyglet.window would just disable rendering rather than crashing. I'll consider that a feature request.

All 5 comments

Yes, it needs OpenGL to run. It's possible to run OpenGL over an SSH connection, usually by running ssh -Y <host>, although it will be slow. See here or here for tips on setting it up.

Thanks for the tips ! Is there a way to turn off opengl completely? because it seems that even if I don't call render () function it still tries to create an empty window

xvfb-run -s "-screen 0 1400x900x24" python <your_script.py> will create a fake X server for it. apt-get xvfb if you don't have it.

It would be better if import pyglet.window would just disable rendering rather than crashing. I'll consider that a feature request.

Thanks a lot for such quick replies !!!

On mac one of these might fix it for you.

If the x window that opens is titled X11:

defaults write org.macports.X11 enable_iglx -bool true

or if it's titled XQuartz:

defaults write org.macosforge.xquartz.X11 enable_iglx -bool true

See here for even more info: https://www.visitusers.org/index.php?title=Re-enabling_INdirect_glx_on_your_X_server

Was this page helpful?
0 / 5 - 0 ratings