我正在通过Jupyter(Ubuntu 14.04)在p2.xlarge AWS服务器上运行python 2.7脚本.我希望能够渲染我的模拟.
最小的工作示例
import gym
env = gym.make('CartPole-v0')
env.reset()
env.render()
Run Code Online (Sandbox Code Playgroud)
env.render() 使(除其他外)以下错误:
...
HINT: make sure you have OpenGL install. On Ubuntu, you can run
'apt-get install python-opengl'. If you're running on a server,
you may need a virtual frame buffer; something like this should work:
'xvfb-run -s \"-screen 0 1400x900x24\" python <your_script.py>'")
...
NoSuchDisplayException: Cannot connect to "None"
Run Code Online (Sandbox Code Playgroud)
我想有些人能够看到模拟.如果我可以将它内联,那将是理想的,但任何显示方法都会很好.
编辑:这只是某些环境的问题,如经典控件.
更新我
灵感来自这个我尝试以下,而不是xvfb-run -s \"-screen 0 1400x900x24\" python <your_script.py>(我不能去上班).
xvfb-run -a jupyter …Run Code Online (Sandbox Code Playgroud) 我正试图在Jupyter笔记本中显示AI-Gym演示.我获得了Atari演示的良好结果Breakout-v0以及购物车极点演示的难度错误消息CartPole-v0.两者在笔记本电脑外都很好用.以下是最小的细节:
在控制台:
$ pip install gym[atari] &> /dev/null
$ /anaconda3/bin/python3
Python 3.6.3 |Anaconda, Inc.| (default, Oct 6 2017, 12:04:38)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import gym
>>> env = gym.make('Breakout-v0')
>>> env.reset()
>>> env.render()
Run Code Online (Sandbox Code Playgroud)
结果:
现在,同样使用cart-pole,在一个新的Python会话中:
$ pip install gym &> /dev/null
$ /anaconda3/bin/python3
Python 3.6.3 |Anaconda, Inc.| (default, Oct 6 2017, 12:04:38)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type …Run Code Online (Sandbox Code Playgroud)