Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: Failed to initialize OpenGL #714

Closed
zichunxx opened this issue May 12, 2022 · 10 comments
Closed

RuntimeError: Failed to initialize OpenGL #714

zichunxx opened this issue May 12, 2022 · 10 comments

Comments

@zichunxx
Copy link

zichunxx commented May 12, 2022

I know this type of problem has been asked many times, and I have tried to follow these methods (#665, #187) to solve my problem, but it seems useless.

Here is my test code:

import mujoco_py

MODEL_XML = """
<?xml version="1.0" ?>
<mujoco>
    <worldbody>
    <camera name="cam0" pos="-0.1 0.1 0.0" quat="0.707 0.707 0 0" />
        <body name="box" pos="0 0 0.2">
            <geom size="0.15 0.15 0.15" type="box"/>
            <joint axis="1 0 0" name="box:x" type="slide"/>
            <joint axis="0 1 0" name="box:y" type="slide"/>
        </body>
        <body name="floor" pos="0 0 0.025">
            <geom size="1.0 1.0 0.02" rgba="0 1 0 1" type="box"/>
        </body>
    </worldbody>
</mujoco>
"""
model = mujoco_py.load_model_from_xml(MODEL_XML)
sim = mujoco_py.MjSim(model)
viewer = mujoco_py.MjViewer(sim)
image = sim.render(width=300, height = 300, camera_name='cam0', depth=False)
print(image)

Then I met the following error:

File "mujoco_py/mjsim.pyx", line 156, in mujoco_py.cymj.MjSim.render
File "mujoco_py/mjsim.pyx", line 158, in mujoco_py.cymj.MjSim.render
File "mujoco_py/mjrendercontext.pyx", line 45, in mujoco_py.cymj.MjRenderContext.__init__
File "mujoco_py/mjrendercontext.pyx", line 113, in mujoco_py.cymj.MjRenderContext._setup_opengl_context
File "mujoco_py/opengl_context.pyx", line 130, in mujoco_py.cymj.OffscreenOpenGLContext.__init__
RuntimeError: Failed to initialize OpenGL

By browsing through some issues, the following code is the reason for this error.

image = sim.render(width='300', height = '300', camera_name='cam0', depth=False)

If I replace this line with viewer.render(), the glfw window will show up. However, this is not the result that I want and the image is not avaliable.

The operating system and mujoco_py which I used are

Linux system: Ubuntu 18.04.
Mujoco_py version: 2.0.2.5.

It seems that unset LD_PRELOAD is useless for me. When I try this method, the window gets stuck and the following error appears

ERROR: GLEW initialization error: Missing GL version

I also have no libGL.so in /usr/lib/nvidia-510, but I'm not sure if this file does have an impact on this issue.

Has anyone successfully solved this problem? I would appreciate a response! Thx!

@DDCoan
Copy link

DDCoan commented Jun 24, 2022

Hi, how did you solve this issue? Could you pls maybe share your solution? many thanks!

@zichunxx
Copy link
Author

zichunxx commented Jun 28, 2022

Hi, how did you solve this issue? Could you pls maybe share your solution? many thanks!

Hi, I'm sorry for replying now. I can't remember the exact details, but I can list all the methods I've tried below.

(1) #187 (comment)

(2) Check the device_id in the programming. Some related issues can be found.

(3) The following two lines of code conflict with each other and cannot be implemented at the same time, which is a bug of Mujoco.

viewer = mujoco_py.MjViewer(sim)
image = sim.render(width=300, height = 300, camera_name='cam0', depth=False)

Hope these are helpful to you!

@DDCoan
Copy link

DDCoan commented Jun 29, 2022

many thanks!

@Irismoon
Copy link

many thanks!

Hi, have you addressed the issue?

Thanks!

@DDCoan
Copy link

DDCoan commented Jul 12, 2022

unset LD_PRELOAD worked for me. did you try that?

@Dimoo-POP
Copy link

unset LD_PRELOAD worked for me. did you try that?

Hi! Should this command (unset LD_PRELOAD) be entered in the terminal, before starting the IDE?

@DDCoan
Copy link

DDCoan commented Jul 12, 2022

you can enter unset LD_PRELOAD in terminal then "python yourfile.py to run your code

@Dimoo-POP
Copy link

you can enter unset LD_PRELOAD in terminal then "python yourfile.py to run your code

Thank you!

@Irismoon
Copy link

unset LD_PRELOAD worked for me. did you try that?

Yes, I tried that. But that did not help with the error. And finally this problem is addressed by using GPU in my case.

@irfanrah
Copy link

unset LD_PRELOAD worked for me. did you try that?

Hi, I tried this and got this error

Creating window glfw
ERROR: GLEW initalization error: Missing GL version
Press Enter to exit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants