openai / mujoco-py

MuJoCo is a physics engine for detailed, efficient rigid body simulations with contacts. mujoco-py allows using MuJoCo from Python 3.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GLEW initalization error: Missing GL version

LiterallyUniqueLogin opened this issue · comments

I'm getting this issue when running
import gym
env = gym.make('Ant-v2')

Mujoco works fine on my machine, I can get the simulations up and running. I've seen this thread but none of the suggestions seem to help.

Any debugging suggestions? What .so files should I expect to have? Where should I expect to find them? What packages should I have installed via apt-get? I'm wondering if one of my installations went wrong somehow.

I'm running on Ubuntu 16.04 with an NVIDIA GeForce GTX 980M graphics card and graphics drivers installed, though I'm not sure that's relevant to this problem.

The solution at the bottom of this thread on the openaigym repo seems to work. (The key part being export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so)

The solution at the bottom of this thread on the openaigym repo seems to work. (The key part being export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so)

If you still have some issues try this out (for Ubuntu, I use Ubuntu 18.04)
Step 1
Run update command to update package repositories and get the latest package information.
sudo apt-get update -y
Step 2
Run the install command with -y

flag to quickly install the packages and dependencies.
sudo apt-get install -y libglew-dev

Got these from : https://zoomadmin.com/HowToInstall/UbuntuPackage/libglew-dev
and then
Step 3:
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so

This worked for me. Hope it works for you.

sudo reboot worked for me in Ubuntu 20.04

The solutions explained here may work for some installations. However, I am using different simulation environments and can't employ the methods mentioned here. I came up with a quick fix by initializing a dummy GL window before rendering! it is patchy but gets the job done.

I added this to the GYM's own observation wrapper PixelObservationWrapper:

import OpenGL.GLUT as gl
def __init__(....
          # Creating a dummy GL Windows to bupas the Error: "GLEW initalization error: Missing GL version"
          gl.glutInit()
          gl.glutInitWindowSize(10, 10)
          gl.glutCreateWindow('GLEW Testing')
....

The export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so solution above initially fixed the problem for me. Something changed in the months since then (no idea what), and I started getting the error again.

The solution was to remove the export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so line from the .bashrc (or from the PyCharm env variables). Hopefully this hint saves someone else the hours it took me to figure this out :)

On arch Linux
export LD_PRELOAD=/usr/lib/libGLEW.so worked for me