Gym: render suddenly producing 1000x1000 frame size videos

Created on 7 Dec 2016  路  5Comments  路  Source: openai/gym

I'm running walker2D and suddenly my videos are twice as large: 1000x1000 instead of 500x500. Needless to say this is slowing down my training considerably.

In video_recorder.py, line 106: frame = self.env.render(mode=render_mode)

the frame now is 1000x1000. Any one with thoughts on how to get this back to normal?
thanks,
john

mujoco

Most helpful comment

Stab in the dark - you could try setting a lower screen res with this and see if it helps: https://itunes.apple.com/au/app/display-menu/id549083868

All 5 comments

In OSX with Retina displays, when you ask for an OpenGL window of a given size, it multiplies the size by the pixel ratio (usually 2). The result looks nice on screen. You ask for a 500x500 window and you get something about 5x5 inches.

The surprising thing is that OSX OpenGL also multiplies the size for off-screen frame buffers by the pixel ratio of some recently used monitor (if you have an external non-high-dpi monitor, you might get either depending on what display OSX thinks python is associated with). So mujoco_py calls

    gl.glRenderbufferStorage(gl.GL_RENDERBUFFER, gl.GL_RGBA, 500, 500)

and gets a 1000x1000 buffer.

You might get different results depending on python version, glfw version, whether python is opening other windows (such as matplotlib).

Can you tell us about your configuration (osx version, glfw version, any monitors connected)?

Related: https://github.com/vispy/vispy/issues/99
https://github.com/glfw/glfw/issues/677

Thanks! I am running OSX 10.11.6 and glfw version 3. I have been hooked up to a Dell U3014 and python is not opening any other windows. I am traveling now so not hooked up to the Dell and it is still producing the large files.

Stab in the dark - you could try setting a lower screen res with this and see if it helps: https://itunes.apple.com/au/app/display-menu/id549083868

Here's a patch to gym to fix your immediate problem, until we figure out how to fix opengl scaling generally:

diff --git a/gym/envs/mujoco/mujoco_env.py b/gym/envs/mujoco/mujoco_env.py
index 1f0dcca..048780e 100644
--- a/gym/envs/mujoco/mujoco_env.py
+++ b/gym/envs/mujoco/mujoco_env.py
@@ -116,7 +116,7 @@ class MujocoEnv(gym.Env):

     def _get_viewer(self):
         if self.viewer is None:
-            self.viewer = mujoco_py.MjViewer()
+            self.viewer = mujoco_py.MjViewer(init_width=250, init_height=250)
             self.viewer.start()
             self.viewer.set_model(self.model)
             self.viewer_setup()

JobJob I tried your suggestion and it works. Thanks so much. tlbtlbtlb your idea works great too. Now I can even make it smaller!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RuofanKong picture RuofanKong  路  3Comments

lbbc1117 picture lbbc1117  路  3Comments

pdoongarwal picture pdoongarwal  路  4Comments

mdavis-xyz picture mdavis-xyz  路  3Comments

tylerlekang picture tylerlekang  路  3Comments