0

https://colab.research.google.com/drive/1ZmFhb0j0yqPuMtgrkeqYkQ3v8qm0Xr1l?usp=sharing

Up until several weeks ago, this Google Colab notebook worked fine - all it is is setting up a Gym environment, having the agent randomly choose actions, and then record and visualize the result - all within a Google Colab notebook. There's not even any actual learning going on here.

Google Colab suddenly decided that it's only going to support Tensorflow 2, which has introduced a host of compatibility issues, and almost every Colab notebook that I've found that demonstrates Deep reinforcement learning with Open AI Gym is now simply broken.

In the notebook linked above, I've gotten at least everything to run except for the last cell. Traceback included below.

gym/envs/classic_control/rendering.py - seems to throw an error with .get_data() : TypeError: get_data() missing 2 required positional arguments: 'format' and 'pitch'

I've found a couple links regarding correctly calling this new get_data() with format and pitch, but I'm not sure what's the most elegant way to solve this issue. Should I try to try to locally rewrite this function call so it takes in the correct argument sequence?


TypeError                                 Traceback (most recent call last)
<ipython-input-19-0c4a02550ae0> in <module>
      1 # Record & show video
----> 2 record_video(env_id, video_length=2000, prefix='random_agent')
      3 show_videos('videos', prefix='random_agent')

7 frames
<ipython-input-15-a4b0623bbfac> in record_video(env_id, video_length, prefix, video_folder)
     23                               name_prefix=prefix)
     24 
---> 25   obs = eval_env.reset()
     26   print("env.reset() shape: %s" %str(obs.shape))
     27 

/usr/local/lib/python3.7/dist-packages/stable_baselines3/common/vec_env/vec_video_recorder.py in reset(self)
     66     def reset(self) -> VecEnvObs:
     67         obs = self.venv.reset()
---> 68         self.start_video_recorder()
     69         return obs
     70 

/usr/local/lib/python3.7/dist-packages/stable_baselines3/common/vec_env/vec_video_recorder.py in start_video_recorder(self)
     78         )
     79 
---> 80         self.video_recorder.capture_frame()
     81         self.recorded_frames = 1
     82         self.recording = True

/usr/local/lib/python3.7/dist-packages/gym/wrappers/monitoring/video_recorder.py in capture_frame(self)
    130 
    131         render_mode = "ansi" if self.ansi_mode else "rgb_array"
--> 132         frame = self.env.render(mode=render_mode)
    133 
    134         if frame is None:

/usr/local/lib/python3.7/dist-packages/stable_baselines3/common/vec_env/dummy_vec_env.py in render(self, mode)
     85         """
     86         if self.num_envs == 1:
---> 87             return self.envs[0].render(mode=mode)
     88         else:
     89             return super().render(mode=mode)

/usr/local/lib/python3.7/dist-packages/gym/core.py in render(self, mode, **kwargs)
    293 
    294     def render(self, mode="human", **kwargs):
--> 295         return self.env.render(mode, **kwargs)
    296 
    297     def close(self):

/usr/local/lib/python3.7/dist-packages/gym/envs/box2d/bipedal_walker.py in render(self, mode)
    562         self.viewer.draw_polyline(f + [f[0]], color=(0, 0, 0), linewidth=2)
    563 
--> 564         return self.viewer.render(return_rgb_array=mode == "rgb_array")
    565 
    566     def close(self):

/usr/local/lib/python3.7/dist-packages/gym/envs/classic_control/rendering.py in render(self, return_rgb_array)
    134             buffer = pyglet.image.get_buffer_manager().get_color_buffer()
    135             image_data = buffer.get_image_data()
--> 136             arr = np.frombuffer(image_data.get_data(), dtype=np.uint8)
    137             # In https://github.com/openai/gym-http-api/issues/2, we
    138             # discovered that someone using Xmonad on Arch was having

TypeError: get_data() missing 2 required positional arguments: 'format' and 'pitch'
Dsig
  • 1

0 Answers0