robosuite icon indicating copy to clipboard operation
robosuite copied to clipboard

AttributeError: 'MjRenderContextOffscreen' object has no attribute 'con' - 2.0 ...

Open neelbg01 opened this issue 10 months ago • 10 comments

Hey there,

Firstly, I am aware of the issues related in #469 as well the other issue listed in that post however after following some of the steps in that post I am still running into the same issue and I don't understand why that would happen. Below is the error I am running into

`the default IK controller setting for GR1 robot. (__init__.py:40)
libEGL warning: MESA-LOADER: failed to open iris: /usr/lib/dri/iris_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)

libEGL warning: MESA-LOADER: failed to open swrast: /home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/torch/lib/../../../../libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /lib/x86_64-linux-gnu/libLLVM-15.so.1) (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)

/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/glfw/__init__.py:917: GLFWError: (65542) b'EGL: Failed to initialize EGL: EGL is not or could not be initialized'
  warnings.warn(message, GLFWError)
Traceback (most recent call last):
  File "examples/train_bc_rnn.py", line 461, in <module>
    train(config, device=device)
  File "/home/neel/Documents/Thesis/robomimic/robomimic/scripts/train.py", line 99, in train
    env = EnvUtils.create_env_from_metadata(
  File "/home/neel/Documents/Thesis/robomimic/robomimic/utils/env_utils.py", line 229, in create_env_from_metadata
    env = create_env(
  File "/home/neel/Documents/Thesis/robomimic/robomimic/utils/env_utils.py", line 174, in create_env
    env = env_class(
  File "/home/neel/Documents/Thesis/robomimic/robomimic/envs/env_robosuite.py", line 105, in __init__
    self.env = robosuite.make(self._env_name, **kwargs)
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/robosuite/environments/base.py", line 41, in make
    return REGISTERED_ENVS[env_name](*args, **kwargs)
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/robosuite/environments/manipulation/lift.py", line 187, in __init__
    super().__init__(
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/robosuite/environments/manipulation/manipulation_env.py", line 172, in __init__
    super().__init__(
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/robosuite/environments/robot_env.py", line 221, in __init__
    super().__init__(
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/robosuite/environments/base.py", line 158, in __init__
    self._reset_internal()
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/robosuite/environments/manipulation/lift.py", line 394, in _reset_internal
    super()._reset_internal()
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/robosuite/environments/robot_env.py", line 519, in _reset_internal
    super()._reset_internal()
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/robosuite/environments/base.py", line 333, in _reset_internal
    render_context = MjRenderContextOffscreen(self.sim, device_id=self.render_gpu_device_id)
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/robosuite/utils/binding_utils.py", line 214, in __init__
    super().__init__(sim, offscreen=True, device_id=device_id, max_width=max_width, max_height=max_height)
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/robosuite/utils/binding_utils.py", line 113, in __init__
    self._set_mujoco_context_and_buffers()
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/robosuite/utils/binding_utils.py", line 116, in _set_mujoco_context_and_buffers
    self.con = mujoco.MjrContext(self.model._model, mujoco.mjtFontScale.mjFONTSCALE_150)
mujoco.FatalError: gladLoadGL error
Exception ignored in: <function MjRenderContext.__del__ at 0x742ccdf6ed30>
Traceback (most recent call last):
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/robosuite/utils/binding_utils.py", line 198, in __del__
AttributeError: 'MjRenderContextOffscreen' object has no attribute 'con'

My current environment is Ubuntu 22.04.5, running the standard Intel Graphics (Mesa Intel® Graphics (RPL-U)), and I was wondering if my setup's lack of a more powerful GPU may cause this error. I am not too knowledgable in this specific area, so if someone could please help me out it would be much appreciated!!!!!

Cheers

neelbg01 avatar Apr 04 '25 10:04 neelbg01

I think you can still use cpu rendering; try first export MUJOCO_GL=osmesa and then run your script

kevin-thankyou-lin avatar Apr 06 '25 19:04 kevin-thankyou-lin

I get the following error?

[robosuite WARNING] To setup, run: python /home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/robosuite/scripts/setup_macros.py (macros.py:55)
Traceback (most recent call last):
  File "examples/train_bc_rnn.py", line 461, in <module>
    train(config, device=device)
  File "/home/neel/Documents/Thesis/robomimic/robomimic/scripts/train.py", line 99, in train
    env = EnvUtils.create_env_from_metadata(
  File "/home/neel/Documents/Thesis/robomimic/robomimic/utils/env_utils.py", line 229, in create_env_from_metadata
    env = create_env(
  File "/home/neel/Documents/Thesis/robomimic/robomimic/utils/env_utils.py", line 173, in create_env
    env_class = get_env_class(env_type=env_type)
  File "/home/neel/Documents/Thesis/robomimic/robomimic/utils/env_utils.py", line 36, in get_env_class
    from robomimic.envs.env_robosuite import EnvRobosuite
  File "/home/neel/Documents/Thesis/robomimic/robomimic/envs/env_robosuite.py", line 10, in <module>
    import robosuite
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/robosuite/__init__.py", line 1, in <module>
    from robosuite.environments.base import make
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/robosuite/environments/__init__.py", line 1, in <module>
    from .base import REGISTERED_ENVS, MujocoEnv
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/robosuite/environments/base.py", line 13, in <module>
    from robosuite.utils.binding_utils import MjRenderContextOffscreen, MjSim
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/robosuite/utils/binding_utils.py", line 12, in <module>
    import mujoco
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/mujoco/__init__.py", line 48, in <module>
    from mujoco.gl_context import *
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/mujoco/gl_context.py", line 38, in <module>
    from mujoco.osmesa import GLContext as _GLContext
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/mujoco/osmesa/__init__.py", line 31, in <module>
    from OpenGL import GL
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/OpenGL/GL/__init__.py", line 4, in <module>
    from OpenGL.GL.VERSION.GL_1_1 import *
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/OpenGL/GL/VERSION/GL_1_1.py", line 14, in <module>
    from OpenGL.raw.GL.VERSION.GL_1_1 import *
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/OpenGL/raw/GL/VERSION/GL_1_1.py", line 7, in <module>
    from OpenGL.raw.GL import _errors
  File "/home/neel/miniconda3/envs/robomimic_venv/lib/python3.8/site-packages/OpenGL/raw/GL/_errors.py", line 4, in <module>
    _error_checker = _ErrorChecker( _p, _p.GL.glGetError )
AttributeError: 'NoneType' object has no attribute 'glGetError'

neelbg01 avatar Apr 08 '25 04:04 neelbg01

Have there ever been version incompatibilities?

neelbg01 avatar Apr 08 '25 04:04 neelbg01

Same issue. Have you solved it?

Simonlinsx avatar Jun 01 '25 09:06 Simonlinsx

Same issue

jasonjabbour avatar Jun 02 '25 21:06 jasonjabbour

Same issue. Have you solved it?

This fixed it for me!!!

conda install -c conda-forge gcc

jasonjabbour avatar Jun 02 '25 21:06 jasonjabbour

Mhmmm have had this issue for a couple months and the above line didn't seem to fix it

neelbg01 avatar Jul 13 '25 02:07 neelbg01

The following package installation fixes this issue for me.

Good luck!

sudo apt-get install libegl-dev

MsterDC avatar Aug 19 '25 05:08 MsterDC

same problem

humworkb avatar Nov 06 '25 07:11 humworkb

I think you can still use cpu rendering; try first export MUJOCO_GL=osmesa and then run your script

got error: segmentation fault(core dumped)

humworkb avatar Nov 06 '25 07:11 humworkb