openai-gym经典控件在centos服务器上呈现问题

问题描述

我正在与使用健身房中的CartPole-v0的RL合作实验室一起玩。我通过连接到远程centOS 7.3服务器(而不是Google驱动器)的jupyter打开了iPython笔记本。以下代码可在Google colab下正确呈现直角图,但无法在我的jupyter设置下呈现:

!pip install gym[classic_control]
import gym
env = gym.make('CartPole-v0')
env.reset()
img = env.render('rgb_array')
plt.imshow(img)

这是我启动Jupyter笔记本的方式:

xvfb-run -a -s "-screen 0 1400x900x24" jupyter notebook

显然,渲染的图像具有未初始化的尺寸或0尺寸。无论是否使用Jupyter,都是如此。

这是完整的错误:

enter image description here

我在pyglet/image/__init__.py中的错误之前打印了该行

def get_image_data(self):
    # xxx = GLubyte * (len(self.format) * self.width * self.height)
    print(GLubyte,len(self.format),self.width,self.height)  # my code
    buffer = (GLubyte * (len(self.format) * self.width * self.height))()

结果为(4 0 0)(4 1551512832 274094153),据我推断宽度和高度未初始化。但是我对内部不够了解,无法进一步调试。在前一种情况下,MemoryError变成某种错误,表明无法渲染大小为零的图像。

任何见识都值得赞赏。以下是一些相关线程:

How to run OpenAI Gym .render() over a server

https://blog.csdn.net/chestnutss/article/details/100734523

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)