openai / mujoco-py

MuJoCo is a physics engine for detailed, efficient rigid body simulations with contacts. mujoco-py allows using MuJoCo from Python 3.
Other
2.81k stars 810 forks source link

Could not get EGL display #731

Closed YouJiacheng closed 1 year ago

YouJiacheng commented 2 years ago

Describe the bug Failed to initialize OpenGL with message "Could not get EGL display"

To Reproduce

import mujoco_py
import os
xml_path = os.path.join(mujoco_py.utils.discover_mujoco(), 'model', 'humanoid.xml')
model = mujoco_py.load_model_from_path(xml_path)
sim = mujoco_py.MjSim(model)
sim.render(480, 480)

Expected behavior Successfully rendering offscreen

Error Messages

Found 6 GPUs for rendering. Using device 0.
Could not get EGL display
Traceback (most recent call last):
  ... omitted
  File "mjsim.pyx", line 156, in mujoco_py.cymj.MjSim.render
  File "mjsim.pyx", line 158, in mujoco_py.cymj.MjSim.render
  File "mjrendercontext.pyx", line 46, in mujoco_py.cymj.MjRenderContext.__init__
  File "mjrendercontext.pyx", line 114, in mujoco_py.cymj.MjRenderContext._setup_opengl_context
  File "opengl_context.pyx", line 130, in mujoco_py.cymj.OffscreenOpenGLContext.__init__
RuntimeError: Failed to initialize OpenGL

Desktop (please complete the following information):

Environment

Additional context

YouJiacheng commented 1 year ago

After I reinstall Nvidia Driver with OpenGL Driver the problem is solved. And actually only conda install -c conda-forge glew is needed, mesalib(for OSMesa) and glfw(for onscreen GPU rendering) have nothing to do with headless GPU rendering. Also, no CPATH need to be set.