Headless Rendering within a Docker Container #1995
Replies: 2 comments 1 reply
-
I am facing the same issue. Were you able to solve it? |
Beta Was this translation helpful? Give feedback.
-
Also experiencing the same issue. Managed to get it solved by running
and then exporting If you have the nvidia-container-toolkit installed it also appears to sorta work if you replace Still unsure if there's a way to do this without explicit X11 forwarding. Ideally what I want is to be able to render using OpenGL, but not necessarily display things to a window (e.g. so I can simulate a camera as input to a neural network). |
Beta Was this translation helpful? Give feedback.
-
Hi,
I'm a graduate student, using MuJoCo for training RL models. I want to run my models within a docker container.
I'm looking for some help with headless rendering.
First off, below is the docker-file that I'm using to create docker-image.
My script tries to initialize the walker-walk environment and do some training. I have set-up the exact same environment using conda, and everything is fine and working. However, when I try to run the same script from within the docker container I get this error below
/usr/local/lib/python3.8/site-packages/glfw/init.py:914: GLFWError: (65537) b'The GLFW library is not initialized'
warnings.warn(message, GLFWError)
.........
File "/usr/local/lib/python3.8/site-packages/dm_control/suite/wrappers/pixels.py", line 77, in init
pixels = env.physics.render(**render_kwargs)
File "/usr/local/lib/python3.8/site-packages/dm_control/mujoco/engine.py", line 223, in render
camera = Camera(
File "/usr/local/lib/python3.8/site-packages/dm_control/mujoco/engine.py", line 711, in init
if self._physics.contexts.mujoco is not None:
File "/usr/local/lib/python3.8/site-packages/dm_control/mujoco/engine.py", line 533, in contexts
self._make_rendering_contexts()
File "/usr/local/lib/python3.8/site-packages/dm_control/mujoco/engine.py", line 519, in _make_rendering_contexts
mujoco_context = wrapper.MjrContext(self.model, render_context)
File "/usr/local/lib/python3.8/site-packages/dm_control/mujoco/wrapper/core.py", line 608, in init
ptr = ctx.call(mujoco.MjrContext, model.ptr, font_scale)
File "/usr/local/lib/python3.8/site-packages/dm_control/_render/executor/render_executor.py", line 138, in call
return func(*args, **kwargs)
mujoco.FatalError: an OpenGL platform library has not been loaded into this process, this most likely means that a valid OpenGL context has not been created before mjr_makeContext was called
To solve this, I changed the environment variable like so
export MUJOCO_GL=egl
And finally, I get the following error
...
from dm_control import suite
File "/usr/local/lib/python3.8/site-packages/dm_control/suite/init.py", line 24, in
from dm_control.suite import acrobot
File "/usr/local/lib/python3.8/site-packages/dm_control/suite/acrobot.py", line 20, in
from dm_control import mujoco
File "/usr/local/lib/python3.8/site-packages/dm_control/mujoco/init.py", line 18, in
from dm_control.mujoco.engine import action_spec
File "/usr/local/lib/python3.8/site-packages/dm_control/mujoco/engine.py", line 41, in
from dm_control import _render
File "/usr/local/lib/python3.8/site-packages/dm_control/_render/init.py", line 86, in
Renderer = import_func()
File "/usr/local/lib/python3.8/site-packages/dm_control/_render/init.py", line 36, in _import_egl
from dm_control._render.pyopengl.egl_renderer import EGLContext
File "/usr/local/lib/python3.8/site-packages/dm_control/_render/pyopengl/egl_renderer.py", line 39, in
from dm_control._render.pyopengl import egl_ext as EGL
File "/usr/local/lib/python3.8/site-packages/dm_control/_render/pyopengl/egl_ext.py", line 29, in
from OpenGL import EGL
File "/usr/local/lib/python3.8/site-packages/OpenGL/EGL/init.py", line 2, in
from OpenGL.raw.EGL._types import *
File "/usr/local/lib/python3.8/site-packages/OpenGL/raw/EGL/_types.py", line 87, in
raw_eglQueryString = _p.PLATFORM.EGL.eglQueryString
AttributeError: 'NoneType' object has no attribute 'eglQueryString'
I would really appreciate any help or suggestion on how to solve this problem.
Note that I was able to run the script with the X Virtual Framebuffer apprach suggested in issue#350. But, I suspect that the rendering doesn't use GPU and hence quite slow.
Beta Was this translation helpful? Give feedback.
All reactions