libGL error persists, and I've tried everything

23 views (last 30 days)
and I mean I've tried EVERYTHING.
I try starting matlab (2015a, 2014b did the same), and I get this:
$ matlab
libGL error: unable to load driver: radeonsi_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: radeonsi
libGL error: unable to load driver: swrast_dri.so
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: 154 (GLX)
Minor opcode of failed request: 3 (X_GLXCreateContext)
Value in failed request: 0x0
Serial number of failed request: 36
Current serial number in output stream: 39
MATLAB is selecting SOFTWARE OPENGL rendering.
From within matlab, I get only software openGL:
>> opengl info
Version: '2.1 Mesa 7.2'
Vendor: 'Brian Paul'
Renderer: 'Mesa X11'
MaxTextureSize: 2048
Visual: 'Visual 0x9a, (RGBA 32 bits (8 8 8 8), Z depth 16 bits, Hardware acceleration, Double buffer, Antialias 0 samples)'
Software: 'true'
SupportsGraphicsSmoothing: 0
SupportsDepthPeelTransparency: 1
SupportsAlignVertexCenters: 0
Extensions: {114x1 cell}
MaxFrameBufferSize: 4096
I'm not the first to get this, and I've tried every fix I can think of and duckduckgo can find.
  • Firstly, I've assumed that it was a problem with my installation and/or graphics drivers and/or card. See https://forums.gentoo.org/viewtopic-t-1012914.html for some of the other things I've tried, including recompiling my entire system a dozen times, I've tried hardened and non-hardened kernels. I've tried both official and open-source graphics drivers, I've even bought a new card to see if the other was faulty. I've tried different versions / releases, I've tried git sources of latest releases. I've chased down problems in mesa, in X, in KDE, tried wayland and gles to see if they help.
Nothing.
Absolutely no difference.
  • So I've tried other things, like linking libGL in the matlab directory to my system libGL from the official support-team answer here: https://www.mathworks.com/matlabcentral/answers/94805-why-does-my-linux-hardware-opengl-not-work-properly. To start, I did as written and linked just the libGL and not the libGLU:
/usr/local/MATLAB/R2015a/sys/opengl/lib/glnxa64 $ ls -l
lrwxrwxrwx 1 rjs rjs 19 Sep 9 10:30 foolibGL.so.1 -> libGL.so.1.5.070200 % (these were copied so I didn't lose them)
-r-xr-xr-x 1 rjs rjs 3200281 Dec 29 2014 foolibGL.so.1.5.070200 % (these were copied so I didn't lose them)
-r--r--r-- 1 rjs rjs 1377 Dec 29 2014 libGL.rights
lrwxrwxrwx 1 rjs rjs 23 Sep 9 13:59 libGL.so.1 -> /usr/lib/libGL.so.1.2.0
lrwxrwxrwx 1 rjs rjs 23 Sep 9 13:58 libGL.so.1.5.070200 -> /usr/lib/libGL.so.1.2.0
-r--r--r-- 1 rjs rjs 1780 Dec 29 2014 libGLU.rights
lrwxrwxrwx 1 rjs rjs 20 Sep 9 10:29 libGLU.so.1 -> libGLU.so.1.3.070200
-r-xr-xr-x 1 rjs rjs 630382 Dec 29 2014 libGLU.so.1.3.070200
-r--r--r-- 1 rjs rjs 1319 Dec 29 2014 libMesa.rights
No change.
  • I've tried linking the libGLU in the matlab path to my system libGLU as well, that also doesn't work. Actually, it makes it worse, both methods start the same but linking the libGL and not the libGLU gives me errors within matlab whenever I try to plot a graph:
javax.media.opengl.GLException: X11GLXDrawableFactory - Could not initialize shared resources for :0
at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:317)
at jogamp.opengl.SharedResourceRunner.run(SharedResourceRunner.java:295)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.media.opengl.GLException: Startup Class Loader-SharedResourceRunner: Error making temp context(1) current: display 0x7f7de0000e10, context 0x7f7de00bd060, drawable X11OnscreenGLXDrawable[Realized true,
Factory jogamp.opengl.x11.glx.X11GLXDrawableFactory@a17b90b,
and a whole lot of other debug crap I can post if anyone thinks it's useful. Leaving libGL and libGLU both as default to use the matlab-supplied versions actually results in the least errors.
  • I've tried linking my radeon drivers into various directories:
/usr/local/MATLAB/R2015a $ ls */*/*dri* -l
lrwxrwxrwx 1 rjs rjs 29 Sep 9 09:53 bin/glnxa64/radeon_dri.so -> /usr/lib/mesa/radeonsi_dri.so
lrwxrwxrwx 1 rjs rjs 31 Sep 9 09:53 bin/glnxa64/swrast_dri.so -> /usr/lib/mesa/kms_swrast_dri.so
-r--r--r-- 1 rjs rjs 23551 Feb 3 2015 help/compiler/deploying-a-standalone-application-on-a-network-drive-windows-only.html
lrwxrwxrwx 1 rjs rjs 29 Sep 9 09:46 runtime/glnxa64/radeonsi_dri.so -> /usr/lib/mesa/radeonsi_dri.so
lrwxrwxrwx 1 rjs rjs 31 Sep 9 09:52 runtime/glnxa64/swrast_dri.so -> /usr/lib/mesa/kms_swrast_dri.so
/usr/local/MATLAB/R2015a $ ls */*/*/*dri* -l
lrwxrwxrwx 1 rjs rjs 29 Sep 9 09:56 bin/glnxa64/graphicssystems/radeon_dri.so -> /usr/lib/mesa/radeonsi_dri.so
lrwxrwxrwx 1 rjs rjs 31 Sep 9 09:56 bin/glnxa64/graphicssystems/swrast_dri.so -> /usr/lib/mesa/kms_swrast_dri.so
lrwxrwxrwx 1 rjs rjs 29 Sep 9 09:50 sys/os/glnxa64/radeon_dri.so -> /usr/lib/mesa/radeonsi_dri.so
lrwxrwxrwx 1 rjs rjs 29 May 26 13:20 sys/os/glnxa64/radeonsi_dri.so -> /usr/lib/mesa/radeonsi_dri.so
lrwxrwxrwx 1 rjs rjs 31 Sep 9 09:51 sys/os/glnxa64/swrast_dri.so -> /usr/lib/mesa/kms_swrast_dri.so
lrwxrwxrwx 1 rjs rjs 28 May 26 13:20 sys/os/glnxa64/swrastg_dri.so -> /usr/lib/mesa/swrastg_dri.so
and so forth. Again, no difference.
  • I've also read that it can be a missing libstdc++ problem. For a start, my matlab or whatever toolboxes I've got installed a libstdc++ for me, so I didn't need to link to my system libstdc++. But I tried it anyway:
/usr/local/MATLAB/R2015a/sys/os/glnxa64 $ ls -l *stdc*
lrwxrwxrwx 1 rjs rjs 21 May 26 13:44 foolibstdc++.so.6 -> ./libstdc++.so.6.0.17 % (again, just so I don't lose them)
-r-xr-xr-x 1 rjs rjs 6345639 Dec 29 2014 foolibstdc++.so.6.0.17 % (again, just so I don't lose them)
lrwxrwxrwx 1 rjs rjs 27 Sep 9 15:00 libstdc++.so -> /usr/lib/libstdc++.so.5.0.7
lrwxrwxrwx 1 rjs rjs 27 Sep 9 15:00 libstdc++.so.5 -> /usr/lib/libstdc++.so.5.0.7
lrwxrwxrwx 1 rjs rjs 27 Sep 9 15:00 libstdc++.so.5.0 -> /usr/lib/libstdc++.so.5.0.7
lrwxrwxrwx 1 rjs rjs 27 Sep 9 15:00 libstdc++.so.5.0.7 -> /usr/lib/libstdc++.so.5.0.7
lrwxrwxrwx 1 rjs rjs 27 Sep 9 15:01 libstdc++.so.6 -> /usr/lib/libstdc++.so.5.0.7
lrwxrwxrwx 1 rjs rjs 27 Sep 9 15:01 libstdc++.so.6.0 -> /usr/lib/libstdc++.so.5.0.7
lrwxrwxrwx 1 rjs rjs 27 Sep 9 15:01 libstdc++.so.6.0.17 -> /usr/lib/libstdc++.so.5.0.7
That opens up a whole lot of new errors on startup, along the lines of:
$ matlab
/usr/local/MATLAB/R2015a/bin/glnxa64/need_softwareopengl: /usr/local/MATLAB/R2015a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by /usr/local/MATLAB/R2015a/bin/glnxa64/need_softwareopengl)
/usr/local/MATLAB/R2015a/bin/glnxa64/need_softwareopengl: /usr/local/MATLAB/R2015a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /usr/local/MATLAB/R2015a/bin/glnxa64/need_softwareopengl)
and about 100 more. So I'm not even going to try to link every single one of those to my system libraries.
  • Finally, I've also tried changing my LD_LIBRARY_PATH from within matlab to just point to my /lib and /usr/lib first: setenv('LD_LIBRARY_PATH','/lib:/usr/lib:/usr/local/MATL<snip>') % The rest as copied from getenv.
And that won't even hold a value, when I setenv it, quit and restart matlab, getenv is as before, with no /lib nor /usr/lib values.
So, I can't think of anything else. There really is no way, it seems, to get any sort of openGL working on this system through any fix that someone's had before. Anyone know anything else to try, what more info is needed, etc?
  12 Comments
Aaron Anderson
Aaron Anderson on 3 May 2017
Edited: Aaron Anderson on 3 May 2017
I now have hardware openGL working with -nosoftwareopengl tag after renaming the two symbolic links from @Abhrajit. I did not however need to rename the last.
Debian Stretch Matlab 2017a
William Chamberlain
William Chamberlain on 21 Oct 2018
Edited: William Chamberlain on 21 Oct 2018
For completeness: @Abhrajit's answer worked for me, with Matlab 2016a on Ubuntu 14.04
In my case: in Matlab
>> matlabroot % check which directory I need to update from the Ubuntu command line
ans =
/mnt/nixbig/downloads/matlab_R2016a
in the Ubuntu command line
cd /mnt/nixbig/downloads/matlab_R2016a/
ls -l | grep libsrdc # to check the versions I have
mv libgcc_s.so.1 libgcc_s.so.1.bak
mv libstdc++.so.6 libstdc++.so.6.bak
mv libstdc++.so.6.0.17 libstdc++.so.6.0.17.bak
ls /usr/lib/x86_64-linux-gnu/ | grep libstdc # to check the versions I have
ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22 libstdc++.so
ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 libstdc++.so.6

Sign in to comment.

Answers (3)

Willi Mutschler
Willi Mutschler on 12 Apr 2020
Hi,
I am on Ubuntu 20.04 beta and running the nvidia on-demand prime profile, and get the same error. I can solve this (see the Archwiki) by starting matlab from terminal:
export MESA_LOADER_DRIVER_OVERRIDE=i965; matlab
Or (additionaly) you can change the EXEC in /usr/share/applications/matlab.desktop to:
Exec=env MESA_LOADER_DRIVER_OVERRIDE=i965 matlab -desktop
  2 Comments
Henrik
Henrik on 17 Jun 2021
Edited: Henrik on 17 Jun 2021
Thanks, this worked for me on Ubuntu 21.04 with an Intel integrated graphics desktop (which would otherwise just give softwareopengl).
Mustafa Oguzhan Akdogan
Mustafa Oguzhan Akdogan on 26 Oct 2023
I believe this fix does not belong here. This fix applies to Nvidia gpus.

Sign in to comment.


Willi Mutschler
Willi Mutschler on 26 Apr 2020
I also ran into this issue on my Dell XPS 13 9360 which neither has a NVIDIA or AMD card, but an on-board intel graphics card.
I filed a bug report with MATHWORKS and they proposed two solutions:
  1. Create a file with the name 'java.opts' in the directory where MATLAB is executed (for me this is in '/usr/local/MATLAB/R2020a/bin/glnxa64') with the following line: -Djogl.disable.openglarbcontext=1
  2. If this does not work, then the above solution using export MESA_LOADER_DRIVER_OVERRIDE=i965 is working.
For me both solve my issue.
  1 Comment
Leonardo Ghizoni
Leonardo Ghizoni on 18 Nov 2022
Awesome! The first solutions worked for me as well :-) I'm using Debian 11 with intel graphics. Thanks for the post!

Sign in to comment.


Redouane Boudjemaa
Redouane Boudjemaa on 29 May 2017
Thanks https://www.mathworks.com/matlabcentral/profile/authors/3509132-abhrajit for the answer, it did work for me too Matlab 2017a Ubuntu 16.04 64bits
  1 Comment
Curt Corum
Curt Corum on 21 Oct 2017
The following removed the error/warning for R2017b on Ubuntu 16.04 LTS:
/usr/local/MATLAB/R2017b/sys/os/glnxa64
libstdc++.so -> libstdc++.so.6
libstdc++.so.6 -> /usr/lib/x86_64-linux-gnu/libstdc++.so.6
libstdc++.so.6.0.21 -> /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21

Sign in to comment.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!