Eclectic-Sheep / sheeprl

Distributed Reinforcement Learning accelerated by Lightning Fabric
https://eclecticsheep.ai
Apache License 2.0
300 stars 29 forks source link

Rendering issue with DreamerV2, V3 #77

Closed dtch1997 closed 11 months ago

dtch1997 commented 1 year ago

Thanks for fixing #66 .

I still have issues running Dreamer with DM control.

What works:

What doesn't work:

The error seems to be a rendering issue.

Changing MUJOCO_GL didn't help.

Here's my example script that works, with RBG rendering (but not windowed).

import numpy as np
from dm_control import suite

# Load the environment
random_state = np.random.RandomState(42)
env = suite.load('hopper', 'stand', task_kwargs={'random': random_state})

# Simulate episode with random actions
duration = 4  # Seconds
frames = []
ticks = []
rewards = []
observations = []

spec = env.action_spec()
time_step = env.reset()

while env.physics.data.time < duration:

  action = random_state.uniform(spec.minimum, spec.maximum, spec.shape)
  time_step = env.step(action)
  camera0 = env.physics.render(camera_id=0, height=200, width=200)
  camera1 = env.physics.render(camera_id=1, height=200, width=200)
  print(camera0.shape)
belerico commented 1 year ago

Hi @dtch1997, thanks for reporting this! Yeah, this is a rendering issue. Have you tried, with osmesa, to add also PYOPENGL_PLATFORM=""? Nothing from the howto/learn_in_dmc.md works? Can you also try to add a fake Display from pyvirtualdisplay if you're on an headless machine an see what happens?

dtch1997 commented 1 year ago

Thanks for responding quickly!

I am on a machine that has rendering enabled (my laptop). Pre-pending PYOPENGL_PLATFORM="" doesn't work. The instructions in howto/learn_in_dmc.md suggest to install libglew2.0, but I can only install libglew2.2 through the standard package repositories.

belerico commented 1 year ago

Have you tried to install libglew2.2? Can you try to downgrade mujoco to 2.3.3 and dm_control to 1.0.11?

belerico commented 11 months ago

Hi @dtch1997, have you tried the above suggestions? We have seen that installing mesalib with conda install -c conda-forge mesalib seems to have solved the issue