openai / gym

A toolkit for developing and comparing reinforcement learning algorithms.
https://www.gymlibrary.dev
Other
34.2k stars 8.58k forks source link

[Bug Report] mujoco rendering is not deterministic #3242

Open famishedrover opened 10 months ago

famishedrover commented 10 months ago

Describe the bug Upon initializing a mujoco environment through gym (the issue is with mujoco_py and other packages like metaworld etc as well), when one resets the env and renders it the expected behavior would be that any number of renders would give the same image observation. This is true if the rendering backend is glfw (as on mac), however for other backends egl & omesa this is not true.

Code example When running a simple code :

import gym 
x = gym.make('Humanoid-v2', render_mode='rgb_array')
x.reset(seed=2)
a = x.render()
b = x.render()

print((a!=b).sum())

The expected result should be 0. It is 0 if infact i'm running glfw (either onscreen / ofscreen on mac, or ofscreen with xvfb on headless server). But for egl / omesa backend this is non zero & significantly varies.

System Info Describe the characteristic of your environment:

Checklist

pseudo-rnd-thoughts commented 10 months ago

Could you raise this on gymnasium instead of gym as gym is not longer being maintained https://github.com/farama-Foundation/gymnasium