Remote Renderer for OpenAI Gym. This code for solving a problem as below line to run open ai gym application on remote system like AWS.
pyglet.canvas.xlib.NoSuchDisplayException: Cannot connect to "None"
Need to install packages.
pip install numpy zmq pillow
Need to install xvfb-run application.
sudo apt-get install xvfb
Run pystream.py on local system. If you want to change port, run with argument -p .
python ./pystream.py -p 5555Import RemoteRenderer from pystream to your code.
from pystream import RemoteRendererAnd create instance by with syntax. If you want to changel IP address and port of server, create instance with address and port parameters.
with RemoteRenderer(env, address='192.168.0.101', port=5555) as renderer:
import gym
import numpy as np
from pystream import RemoteRenderer
env = gym.make('CartPole-v0')
with RemoteRenderer(env) as renderer:
env.reset()
for _ in xrange(100):
values = env.step(env.action_space.sample())
renderer.render()
To avoid pyglet.canvas.xlib.NoSuchDisplayException, run on virtual frame buffer by xvfb. You can run script using xvfb.sh easily.
./xvfb.sh [script file]