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

How can i deal with 'libGL error: failed to load driver: swrast.' #509

Closed
lfwin opened this issue Feb 24, 2017 · 17 comments
Closed

How can i deal with 'libGL error: failed to load driver: swrast.' #509

lfwin opened this issue Feb 24, 2017 · 17 comments

Comments

@lfwin
Copy link

lfwin commented Feb 24, 2017

I am using a xrdp remote connecting to a Ubuntu14.04 desktop machine, which successfully installed tensorflow and caffe.
After i install gym and run
import gym env = gym.make('CartPole-v0') env.reset() for _ in range(1000): env.render() env.step(env.action_space.sample()) # take a random action

libGL error occurs.
using "LIBGL_DEBUG=verbose glxgears" , it outputs:
libGL: screen 0 does not appear to be DRI3 capable libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/tls/swrast_dri.so libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so libGL: driver does not expose __driDriverGetExtensions_swrast(): /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so: undefined symbol: __driDriverGetExtensions_swrast libGL: Can't open configuration file /home/lfwin/.drirc: No such file or directory. libGL: Can't open configuration file /home/lfwin/.drirc: No such file or directory. 3751 frames in 5.0 seconds = 750.148 FPS 4278 frames in 5.0 seconds = 855.515 FPS

I googled, but need reinstall nvidia drivers.

EDIT: After i update nvidia drivers, it works in local Ubuntu14.04 desktop machine, but still have error in remote connection

@tlbtlbtlb
Copy link
Contributor

Can you give more detail on what the current problem is?

@lfwin
Copy link
Author

lfwin commented Feb 24, 2017

Hi, @tlbtlbtlb
Now, the problem is when running following code in eclipse in a remote desktop connection using xrdp which connecting to a Ubuntu 14.04 server computer,
import pdb import gym env = gym.make('CartPole-v0') env.reset() for _ in range(1000): env.render() env.step(env.action_space.sample()) # take a random action print("success")
this error below happens:
"
libGL error: failed to load driver: swrast
Traceback (most recent call last):
File "/home/lfwin/workspace/homework/hw1/test_gym.py", line 7, in
env.render()
File "/usr/local/lib/python2.7/dist-packages/gym/core.py", line 174, in render
return self._render(mode=mode, close=close)
File "/usr/local/lib/python2.7/dist-packages/gym/envs/classic_control/cartpole.py", line 142, in _render
return self.viewer.render(return_rgb_array = mode=='rgb_array')
File "/usr/local/lib/python2.7/dist-packages/gym/envs/classic_control/rendering.py", line 84, in render
self.window.dispatch_events()
File "/usr/local/lib/python2.7/dist-packages/pyglet/window/xlib/init.py", line 840, in dispatch_events
self.dispatch_pending_events()
File "/usr/local/lib/python2.7/dist-packages/pyglet/window/xlib/init.py", line 880, in dispatch_pending_events
EventDispatcher.dispatch_event(self, *self._event_queue.pop(0))
File "/usr/local/lib/python2.7/dist-packages/pyglet/event.py", line 365, in dispatch_event
if getattr(self, event_type)(*args):
File "/usr/local/lib/python2.7/dist-packages/pyglet/window/init.py", line 722, in on_resize
gl.glOrtho(0, width, 0, height, -1, 1)
File "/usr/local/lib/python2.7/dist-packages/pyglet/gl/lib.py", line 104, in errcheck
raise GLException(msg)
pyglet.gl.lib.GLException: invalid value
"
if I run above code using shell, it runs well and display:
"
[2017-02-24 21:18:02,573] Making new env: CartPole-v0
success
success
...
"
but not display animation.
but if i run locally on the ubuntu14.04 computer, all goes right.
I want to run on remote windows computer.

@tlbtlbtlb
Copy link
Contributor

You need the swrast driver installed for OpenGL rendering to work in headless mode. Typically, apt-get intall -y mesa-utils and libgl1-mesa-glx will do it. But if you have proprietary video drivers installed, it may take some googling to find the answer.

@lfwin
Copy link
Author

lfwin commented Feb 25, 2017

Hi,
I run test LIBGL_DEBUG=verbose glxinfo|grep renderer, it outputs
PowerEdge-R730:~$ LIBGL_DEBUG=verbose glxinfo|grep renderer
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/tls/swrast_dri.so
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so
libGL: driver does not expose __driDriverGetExtensions_swrast(): /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so: undefined symbol: __driDriverGetExtensions_swrast
libGL: Can't open configuration file /home/lfwin/.drirc: No such file or directory.
libGL: Can't open configuration file /home/lfwin/.drirc: No such file or directory.
libGL error: failed to load driver: swrast

and swarast_dri.so can be find as follows.
PowerEdge-R730:~$ locate swrast_dri.so
/usr/lib/i386-linux-gnu/dri/swrast_dri.so
/usr/lib/x86_64-linux-gnu/dri/swrast_dri.so

Also, video drivers, mesa-utils and libgl1-mesa-glx all upgraded.

@tlbtlbtlb
Copy link
Contributor

It's a common problem with Ubuntu 14.04 and nVidia drivers. Easy solutions are to uninstall the nvidia drivers, or upgrade to Ubuntu 16.04. Many other solutions at https://encrypted.google.com/search?hl=en&q=driver%20does%20not%20expose%20__driDriverGetExtensions_swrast

@frankcarey
Copy link

Note: I fixed this by using nvidia-docker instead

@allenyllee
Copy link

Based on the dockerfile of nvidia/cuda, I can solve this problem.
https://gitlab.com/nvidia/cuda/blob/ubuntu16.04/8.0/runtime/Dockerfile

Or you can just use it with nvidia-docker to create another container run all the stuff without touching your OS environments.

@ruapotato
Copy link

Wait so I'm seeing this in a basic chroot (drivers installed on the host and chroot.. trying to load steam)
what part of the Nvidia docker is fixing this? I don't want to use docker but I want 3d drivers.

@carlsummer
Copy link

VMware Ubuntu

2018/10/20 12:53:47 I1020 12:53:47.639172 3702 gymvnc.go:550] [0:localhost:5900] connection established
libGL error: unable to load driver: vmwgfx_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: vmwgfx
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
Traceback (most recent call last):
universe-iizbj6-0 | [tigervnc] SConnection: Client needs protocol version 3.8
universe-iizbj6-0 | [tigervnc] SConnection: Client requests security type VncAuth(2)

@BuhuanJin
Copy link

When on CentOS7:
yum install -y mesa-libGLw-devel.x86_64

@boogert-lab
Copy link

Thanks BuhuanJin, this solved a lot of problems.

@itayave
Copy link

itayave commented Oct 8, 2020

I deal with it in Redhat-8.2 (aarch64) with installing the mesa driver:

sudo dnf install -y mesa-dri-drivers

@rohanjuneja
Copy link

rohanjuneja commented Feb 20, 2021

I am receiving a similar issue, and it did't get resolved even after updating mesa drivers. Kindly could you please help me with this?

Output of "glxgears":
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 149 (GLX)
Minor opcode of failed request: 3 (X_GLXCreateContext)
Value in failed request: 0x0
Serial number of failed request: 28
Current serial number in output stream: 30

Output of "ldconfig -p | grep -I gl.so"
libwayland-egl.so.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libwayland-egl.so.1
libwayland-egl.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libwayland-egl.so
libcogl.so.20 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libcogl.so.20
libQt5OpenGL.so.5 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libQt5OpenGL.so.5
libQt5OpenGL.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libQt5OpenGL.so
libQtOpenGL.so.4 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libQtOpenGL.so.4
libQtOpenGL.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libQtOpenGL.so
libGL.so.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
libEGL.so.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/mesa-egl/libEGL.so.1
libEGL.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libEGL.so
libEGL.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/mesa-egl/libEGL.so

@samlaf
Copy link

samlaf commented Apr 27, 2021

For future reference, you can run your programs with the prefix LIBGL_DEBUG=verbose to get debug output.
See https://askubuntu.com/a/566522

@Jamlee
Copy link

Jamlee commented Nov 6, 2022

When on CentOS7:
yum install -y mesa-libGLw-devel.x86_64 # not work

yum install -y mesa-dri-drivers # worked for me

@Tectract
Copy link

commmenting for posterity only to help anyone who lands here

For me, I was working on an old ubuntu 14.04 box, after a motherboard replacement and much messing around with the graphics drivers, which for me were old mesa drivers.

I got out my old backup archive HD for this machine and it had a different libGL.so.0.1.2.0 for me to try, in /usr/lib/fglrx

pointing my system /usr/lib/libGL.so and /usr/lib/libGL.so.1 files in a symlink to this /usr/lib/fglrx/libGLS.so.0.1.2.0 worked for me to restore headless libGL working again on this old machine. So if you are getting this error it means you are likely using the wrong version of libGL.so for your machine to load the swrast libs.

@18611429192
Copy link

When on CentOS7: yum install -y mesa-libGLw-devel.x86_64

yeah, thanks. You help me a lot.

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