【问题标题】:openai-gym classic controls rendering issue on centos serveropenai-gym 经典控件在 centos 服务器上的渲染问题
【发布时间】:2021-02-08 06:41:04
【问题描述】:

我正在使用来自健身房的 CartPole-v0 的 RL colab。我通过连接到远程 centOS 7.3 服务器(不是谷歌驱动器)的 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 notebook 的方式:

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

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

这是完整的错误:

我在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

【问题讨论】:

    标签: jupyter-notebook openai-gym


    【解决方案1】:

    我设法通过以下一系列命令解决了环境问题:

    sudo yum install python-xvfbwrapper.noarch
    sudo yum install mesa-dri-drivers
    sudo yum install xorg-devel libglu1-mesa libgl1-mesa-devel libxinerama1 libxcursor1
    sudo yum install glxinfo
    sudo yum -y install freeglut-devel
    

    然后下面的渲染在连接到服务器的jupyter浏览器笔记本中工作

    import gym
    import matplotlib.pyplot as plt
    
    env = gym.make('CartPole-v0')
    env.reset()
    img = env.render('rgb_array')
    plt.imshow(img)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-28
      • 1970-01-01
      • 1970-01-01
      • 2020-11-11
      • 2023-02-23
      • 2022-10-08
      • 1970-01-01
      相关资源
      最近更新 更多