I am getting following error in one the remote server (it also has monitor attached though), while creating CarRacing-v0 environment. However, my other servers are working fine.
Ubuntu 16, gym 0.17.1/2, pyglet 1.5.0
import gym
#env = gym.make("Breakout-v0")
env = gym.make("CarRacing-v0")
obj = env.reset()
xvfb-run -a -s "-screen 0 1400x900x24" python debug-gym.py
/home/rpoudel/miniconda3/envs/py35/lib/python3.5/site-packages/gym/logger.py:30: UserWarning: WARN: Box bound precision lowered by casting to float32
warnings.warn(colorize('%s: %s'%('WARN', msg % args), 'yellow'))
Track generation: 1172..1470 -> 298-tiles track
Traceback (most recent call last):
File "debug-gym.py", line 11, in <module>
obj = env.reset()
File "/home/rpoudel/miniconda3/envs/py35/lib/python3.5/site-packages/gym/wrappers/time_limit.py", line 25, in reset
return self.env.reset(**kwargs)
File "/home/rpoudel/miniconda3/envs/py35/lib/python3.5/site-packages/gym/envs/box2d/car_racing.py", line 311, in reset
return self.step(None)[0]
File "/home/rpoudel/miniconda3/envs/py35/lib/python3.5/site-packages/gym/envs/box2d/car_racing.py", line 323, in step
self.state = self.render("state_pixels")
File "/home/rpoudel/miniconda3/envs/py35/lib/python3.5/site-packages/gym/envs/box2d/car_racing.py", line 407, in render
arr = arr.reshape(VP_H, VP_W, 4)
ValueError: cannot reshape array of size 0 into shape (96,96,4)
Surprising enough, Breakout-v0 works fine as well as CarRacing-v0 on my other server. What might goes wrong?
Thank you so much!
However, when I remove -a option from xvfb
xvfb-run -a -s "-screen 0 1400x900x24" python debug-gym.py
Error message points below,
image_data = pyglet.image.get_buffer_manager().get_color_buffer().get_image_data()
File "/home/rpoudel/miniconda3/envs/py35/lib/python3.5/site-packages/pyglet/image/__init__.py", line 2035, in get_image_data
buffer = (GLubyte * (len(self.format) * self.width * self.height))()
ValueError: Array length must be >= 0, not -74645625240420
It would be great if someone can point me the possible source of error, thanks!
The script seemed to work fine on a linux system when I just tested it. Does xvfb-run glxgears work on your broken system?
Thank you so much @christopherhesse, it's giving following error,
Error: couldn't get an RGB, Double-buffered visual
I met similar problem when deploying CarRacing on a headless server. But I got ValueError: invalid literal for int() with base 10: '' after running xvfb-run -a -s "-screen 0 1400x900x24" python ***py
`
Can't figure out what was the actual problem, however after upgrading to Ubuntu 18.04 solves my problem. Hence, I believe the bug is related with Xorg version/broken. Hence, I am closing the bug.
@rudrapoudel Could you please provide the gym-version you are using, I'm meeting the same problem as you do now?
I used latest version of gym installed with pip on last Saturday.
I have the same issue. Exactly what @rudrapoudel met. Anybody know how to run CarRacing-v0 in headless machine without upgrading the system?
I also observe a weird phenomenon. When self.render() is called in the first time, the memory consumption on my remote server increases drastically (up to 80G for only single CarRacing-v0 environment). I am not sure what this related to the render issue that return wrong data when calling image_data = pyglet.image.get_buffer_manager().get_color_buffer().get_image_data()
Anyone find a fix for this? I'm facing the same issue (ValueError: cannot reshape array of size 0 into shape (96,96,4) from this snippet). I've searched around but couldn't find anything useful. Neither does the pyglet website talk about this.
Based on what @rudrapoudel posted above, seems like some system packages are incompatible. Also I'm in a place where I can't update the Linux OS. I've experimented on 2 different systems on the server (one with gpu and the other without, if that matters) and it seems to work fine on the cpu, but not on the gpu machine.