The solution of the render() function in gym running on the cloud server

Original source: https://blog.csdn.net/wobeatit/article/details/106313945

Recently, when running the gym environment, I encountered the following problems:

pyglet.canvas.xlib.NoSuchDisplayException: Cannot connect to "None"

Habitually Google searched for a wave of solutions, and found that the fuse for this type of problem mainly pointed to that the render() function in the gym was called at the remote end. Because this function is required to run on the local end, it will open a window locally for rendering the image of the environment. Once the problem is located, then think about a wave of solutions. First of all, it is impossible to run this locally on the local side. After all, it is affected by the epidemic. I use the resources of the remote server to run the code every day. My own small notebook has really good computing power. Can't keep up. Ever since, I continue to look for solutions. Since there are so many people in the world engaged in Reinforcement Learning, and many scientific researchers have the idea of ​​running Atari experiments on servers, there should be solutions to such problems. Sure enough, I found an English blog and gave some solutions: Extending OpenAI Gym environments with Wrappers and Monitors [Tutorial].

Regarding the content of the blog, it mainly introduces the Wrapper and Monitor components in the gym. For specific details on the usage of these components, please refer to the blog. In response to the problem I encountered here, there is an idea, that is, since a window needs to be opened on the local side, can I try to start virtualized graphics rendering on the server side by using a virtual image rendering method. Very good point is that there are so called under Linux xvfbpackages, you can do it. It can start a virtual graphic display on the server and force the program to draw in it. xvfbInstallation method:

yum install Xvbf

Calling method:

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

Among them, in the process of calling, another problem was encountered:, AttributeError: 'ImageData' object has no attribute 'data'looking at everyone's feedback on the Internet, it is the version of pyglet. You need to specify a specific version of pyglet to install:

pip install pyglet==1.3.2

After the installation is complete, continue to execute the program and run smoothly. At this point, the stepping on the pit ends.

references

[1] Extending OpenAI Gym environments with Wrappers and Monitors [Tutorial]
[2] StackOverflow. How to run OpenAI Gym .render() over a server

Guess you like

Origin blog.csdn.net/SL_World/article/details/113997415