I am playing with the RL colab that uses CartPole-v0 from gym. I opened the iPython notebook through jupyter connected to a remote centOS 7.3 server (not google drive). The following code renders the cartpole diagram correctly under google colab, but not with my jupyter setup:
!pip install gym[classic_control]
import gym
env = gym.make('CartPole-v0')
env.reset()
img = env.render('rgb_array')
plt.imshow(img)
Here is how I started my jupyter notebook:
xvfb-run -a -s "-screen 0 1400x900x24" jupyter notebook
Apparently the rendered image has either uninitialized dimensions or 0 dimensions. This is True whether using Jupyter or not.
I printed out the line just before the error in 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))()
The results are either (4 0 0)
or (4 1551512832 274094153)
, from which I infer the width and height are uninitialized. But I don't understand the internal well enough to debug further. In the former case, MemoryError becomes something error that says cannot render an image of size zero.
Any insight is appreciated. Here are some relevant threads: