dm_control icon indicating copy to clipboard operation
dm_control copied to clipboard

Can the viewer work properly on WSL2?

Open mantle2048 opened this issue 2 years ago • 0 comments

Hello,

I am trying to call the viewer on WSL2 (ubuntu20.04 with WSLg) and followed the example:

    env = suite.load(domain_name="humanoid", task_name="stand")
    action_spec = env.action_spec()

    # Define a uniform random policy.
    def random_policy(time_step):
        del time_step  # Unused.
        return np.random.uniform(low=action_spec.minimum,
                                high=action_spec.maximum,
                                size=action_spec.shape)
    viewer.launch(
        env, policy=random_policy,
    )

However, I got an error:

OpenGL.error.Error: Attempt to retrieve context when no valid context

Error info
Traceback (most recent call last):
  File "test_gym.py", line 64, in <module>
    dmc_rollout("humanoid_run")
  File "test_gym.py", line 57, in dmc_rollout
    viewer.launch(
  File "/home/yan/miniconda3/envs/RL/lib/python3.8/site-packages/dm_control/viewer/__init__.py", line 39, in launch
    app = application.Application(title=title, width=width, height=height)
  File "/home/yan/miniconda3/envs/RL/lib/python3.8/site-packages/dm_control/viewer/application.py", line 187, in __init__
    self._window = gui.RenderWindow(width, height, title)
  File "/home/yan/miniconda3/envs/RL/lib/python3.8/site-packages/dm_control/viewer/gui/glfw_gui.py", line 196, in __init__
    self._fullscreen_quad = ctx.call(self._glfw_setup, self._context.window)
  File "/home/yan/miniconda3/envs/RL/lib/python3.8/site-packages/dm_control/_render/executor/render_executor.py", line 138, in call
    return func(*args, **kwargs)
  File "/home/yan/miniconda3/envs/RL/lib/python3.8/site-packages/dm_control/viewer/gui/glfw_gui.py", line 204, in _glfw_setup
    return fullscreen_quad.FullscreenQuadRenderer()
  File "/home/yan/miniconda3/envs/RL/lib/python3.8/site-packages/dm_control/viewer/gui/fullscreen_quad.py", line 66, in __init__
    self._init_shaders()
  File "/home/yan/miniconda3/envs/RL/lib/python3.8/site-packages/dm_control/viewer/gui/fullscreen_quad.py", line 95, in _init_shaders
    GL.glVertexAttribPointer(
  File "src/latebind.pyx", line 51, in OpenGL_accelerate.latebind.Curry.__call__
  File "/home/yan/miniconda3/envs/RL/lib/python3.8/site-packages/OpenGL/GL/VERSION/GL_2_0.py", line 469, in glVertexAttribPointer
    contextdata.setValue( key, array )
  File "/home/yan/miniconda3/envs/RL/lib/python3.8/site-packages/OpenGL/contextdata.py", line 59, in setValue
    context = getContext( context )
  File "/home/yan/miniconda3/envs/RL/lib/python3.8/site-packages/OpenGL/contextdata.py", line 38, in getContext
    context = platform.GetCurrentContext()
OpenGL.error.Error: Attempt to retrieve context when no valid context

mantle2048 avatar Feb 25 '23 15:02 mantle2048