3

I was trying to run the CartPole-v0 example on a Google Compute Engine VM. https://gym.openai.com/docs

import gym
env = gym.make('CartPole-v0')
env.reset()
for _ in range(1000):
    env.render()
    env.step(env.action_space.sample()) # take a random action

I have XQuartz installed, and ssh with -X.

First, I was getting pyglet.canvas.xlib.NoSuchDisplayException: Cannot connect to "None"

Then according to http://www.gitterforum.com/discussion/openai-gym?page=28, I use "xvfb-run -s "-screen 0 1400x900x24" /bin/bash"

Then it ran fine with the result:

Making new env: CartPole-v0
You are calling 'step()' even though this environment has already returned done = True. You should always call 'reset()' once you receive 'done = True' -- any further steps are undefined behavior

But there is nothing rendered...

Luffy
  • 31
  • 1
  • 3

1 Answers1

2

Use code from Observations section on https://gym.openai.com/docs.

Ivan
  • 21
  • 1