Hardware OpenGL Failure on Ubuntu 16.04.3 - Can not initialize shared resources
Afficher commentaires plus anciens
First, my system info:
- 4.13.0-26-generic #29~16.04.2-Ubuntu SMP Tue Jan 9 22:00:44 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
- Clean installation of Matlab R2016b (64-bit)
- Video card: AMD/ATI Pitcairn PRO (Radeon HD 7850)
Problems with Vanilla Install
So, I start up Matlab from the command line with no arguments. I've set two environment variables, LIBGL_DEBUG=verbose and MESA_DEBUG=1, to get an idea of any bugs. The software starts with no errors. Next, I issue a simple plot command:
plot(1,1, 'b*'); grid on;
Matlab creates the plot successfully, but issues a series of errors, saying that there was a low-level graphics error. From the command line I see the following messages:
libGL: pci id for fd 570: 1002:6819, driver radeonsi
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/tls/radeonsi_dri.so
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/radeonsi_dri.so
libGL: dlopen /usr/lib/x86_64-linux-gnu/dri/radeonsi_dri.so failed (/opt/local/MATLAB/R2016b/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /usr/lib/x86_64-linux-gnu/dri/radeonsi_dri.so))
There are many more, but the end result is the same: the linker cannot load the graphics drivers with the libstdc++.so file Matlab has loaded. To fix this issue, I rename the relevant libraries that come with Matlab to force it to use the system libraries (which include version GLIBCXX_3.4.21):
cd /opt/local/MATLAB/R2016b/sys/os/glnxa64
mv libstdc++.so.6 libstdc++.so.6.bak
mv libstdc++.so.6.0.20 libstdc++.so.6.0.20.bak
Problems with Modified Install
With the C++ libraries renamed to force Matlab to link with the system libraries, I restart Matlab. The environment variables are still set, so any libgl or mesa errors should be reported to the terminal. Immediately after the program starts, I receive the following error in Matlab:
com.jogamp.opengl.GLException: X11GLXDrawableFactory - Could not initialize shared resources for X11GraphicsDevice[type .x11, connection :1, unitID 0, handle 0x0, owner false, ResourceToolkitLock[obj 0x7c1bc33e, isOwner false, <2af5b1a, 46860956>[count 0, qsz 0, owner <NULL>]]]
at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:326)
at jogamp.opengl.SharedResourceRunner.run(SharedResourceRunner.java:297)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:688)
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:580)
at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:297)
... 2 more
Exception in thread "Startup Class Loader" java.lang.InternalError: XXX0 profile[1]: GL3bc -> profileImpl GL4bc !!! not mapped
at com.jogamp.opengl.GLProfile.computeProfileMap(GLProfile.java:2047)
at com.jogamp.opengl.GLProfile.initProfilesForDeviceCritical(GLProfile.java:1917)
at com.jogamp.opengl.GLProfile.initProfilesForDevice(GLProfile.java:1866)
at com.jogamp.opengl.GLProfile.initProfilesForDefaultDevices(GLProfile.java:1835)
at com.jogamp.opengl.GLProfile.access$000(GLProfile.java:79)
at com.jogamp.opengl.GLProfile$1.run(GLProfile.java:229)
at java.security.AccessController.doPrivileged(Native Method)
at com.jogamp.opengl.GLProfile.initSingleton(GLProfile.java:215)
at com.mathworks.hg.peer.JavaSceneServerPeer.initializeJOGL(JavaSceneServerPeer.java:147)
at com.mathworks.hg.peer.JavaSceneServerPeer.<clinit>(JavaSceneServerPeer.java:117)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.mathworks.mde.desk.StartupClassLoader.loadClass(StartupClassLoader.java:262)
at com.mathworks.mde.desk.StartupClassLoader.access$900(StartupClassLoader.java:25)
at com.mathworks.mde.desk.StartupClassLoader$2.run(StartupClassLoader.java:248)
at java.lang.Thread.run(Unknown Source)
Additionally, the following messages are displayed in the Terminal output:
libGL: pci id for fd 570: 1002:6819, driver radeonsi
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/tls/radeonsi_dri.so
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/radeonsi_dri.so
libGL: Using DRI3 for screen 0
These messages don't indicate any troubles; it looks like the radeonsi_dri object is loaded successfully. When I try the same plot command as above, I receive the following message in Matlab:
Caught unexpected fl::except::IInternalException
The figure shows an empty image; the plot has not been created.
Other Notes
- I've also tried renaming the libgcc_s.so.1 library in Matlab's directory so that it uses the system version, but that doesn't change anything.
- There are no errors (EE) in my Xorg.0.log file
- I've successfully benchmarked OpenGL and the video card with glmark2, i.e., OpenGL runs very well with hardware accelleration on my machine, but Matlab has some issue.
- Matlab R2016b ships with libGL.so.1.6.0 (in R2016b/sys/opengl/lib/glnxa64) but my OS version is libGL.so.1.2.0). Could this cause an issue? I tried renaming the libGL files shipped with Matlab to force it to use the system versions, but the error messages are still the same.
- With the modified libstdc++ files, I can run Matlab in software openGL mode via the command matlab -softwareopengl. Plotting works fine, though Mesa spits out the warning/error, "User error: GL_INVALID_ENUM in glGetIntegerv(pname=GL_MAJOR_VERSION)"
12 commentaires
I got the same error output on Matlab startup described under "Problems with Modified Install". It seems that no PLOT commands can be executed. Each is terminated by "Caught unexpected fl::except::IInternalException."
Some system info: - Ubuntu 16.04.3 - Matlab 2016a (set for usage of psychtoolbox-3, programmed experiments run fine, no timing issues) - Radeon HD580 (open amdgpu driver)
Furthermore opengl info gives this rather useless output: Version: '' Vendor: '' Renderer: 'None' RendererDriverVersion: '' RendererDriverReleaseDate: '' MaxTextureSize: 0 Visual: '' Software: 1 HardwareSupportLevel: 'none' SupportsGraphicsSmoothing: 0 SupportsDepthPeelTransparency: 0 SupportsAlignVertexCenters: 0 Extensions: {} MaxFrameBufferSize: 0
Yubo Qiu
le 25 Jan 2018
I've ran into the same issue. Currently using Linux Mint 18.3 with a fresh install of Matlab. I've attached the screenshot of the error. I used this code to launch Matlab
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/local/MATLAB/R2017b/bin/matlab
Using AMD280X
Nico Bast
le 25 Jan 2018
I read that this comment should prevent matlab from using its outdated libstdc library and instead get the systems libstdc. This change of libraries is also done by the "matlab-support" package.
- source: https://github.com/Psychtoolbox-3/Psychtoolbox-3/wiki/Cookbook:-Setting-up-Ubuntu-with-Modern-AMD-Cards
However, neither the preload command nor the matlab-support package help. I still get the errors described under "Problems with Modified Install". To elaborate a little more on this:
- opengl info just returns empty values (no hardware acceleration?) - I cannot plot anything (e.g. plot(1,1)) - however, my experiments with psychtoolbox-3 run fine with good timings. The GPU is adequately addressed.
Does somebody have any suggestions, how to proceed? Thanks and Best,
Andrew Cox
le 25 Jan 2018
Nico Bast
le 26 Jan 2018
Dear Andrew,
the tools in Psychtoolbox that create xorg.conf.d files are the XOrgConfCreator and the XOrgConfSelector that can be called within maltab and implemented Psychtoolbox. However, these tools are just for setting up Screens and Display. I would not think that they are related to our problem.
- I found that the error messages described under "Problems with modified install" to not appear if I uninstall psychtoolbox-3. However, ptb3 is mandatory for me.
Domanic
le 26 Jan 2018
Issuing the following as your first matlab command sometimes offers a workaround for similar issues:
opengl neverselect
Andrew Cox
le 26 Jan 2018
Thad C
le 2 Fév 2018
Having the exact same maddening series of problems/errors with my system. I've also been through the same set of solution attempts with matlab-support pkg.
Installing the amdgpu-pro driver sidesteps the total crash on Matlab startup, but comes with its own bevy of errors/workarounds/warnings when attempting to do anything Psychtoolbox related (...the only reason for machine existence).
Switching to an nvidia gpu and proprietary nvidia driver has the same effect; runs, but broken in other ways.
Seems like this all points to something fundamentally messed up in current Ubuntu 16.04 open source driver implementation(?), the way it interacts with Matlab 2016b's own [inherently broken] OpenGL implementation(?), or remappings done by the matlab-support package(?)...or some combination thereof.
Not trying to point fingers, just want to make some kind of sense out of this dumb low-level crashing, and get back to work!
System & hardware:
- Ubuntu 16.04 (fully apt-get up to date as of Feb.2, 2018)
- AMD Radeon Pro WX 7100
- Matlab 2016b
- ...followed additional package install advice on Psychtoolbox-3 github wiki cookbook (<https://github.com/Psychtoolbox-3/Psychtoolbox-3/wiki/Cookbook%253A-Setting-up-Ubuntu-with-Modern-AMD-Cards PTB cookbook>)
Andrew Cox
le 5 Fév 2018
Good to know, Andrew. ...this is looking more and more like something got screwed up in the opensource driver stack early this year.
I did a few iterations of clean installs of Ubuntu 16.04 and 17.10, and all paths end up in the same failure state after running 'sudo apt update && sudo apt upgrade'. ...I have only new/clean installs to work with, and starting from a fresh Ubuntu 16.04 there are currently 200+ packages with available updates, thus potential culprits for screwing up opengl links (more experienced linux users surely know ways of narrowing that down...?).
As time passes and more [unfortunate] people run 'apt upgrades' that trigger this error , there seem to be more people slipping into the same non-functional state, so hopefully this will get sorted out soon.
I posted similar/cross-referenced information about this error in this Psychtoolbox forum message : https://groups.yahoo.com/neo/groups/psychtoolbox/conversations/messages/22674 So keep an eye out there, and we'll try to cross pollinate any viable solutions & workarounds as the come up.
Moritz Oberjatzas
le 7 Fév 2018
Hello,
I can confirm this problem with Matlab R2017b on a Gentoo Linux installation. It looks like the problem is related to an update of the media-libs/mesa package (on Gentoo). They changed the naming of the renderer and the java opengl implementation in Matlab is not longer able to correctly identify it. Look here: https://jogamp.org/bugzilla/show_bug.cgi?id=1357#c5
A workaround is to downgrade the mesa package (for me it was from 17.2.8 to 17.1.10). After that, hardware acceleration works as expected. Anyways, I also would be interested in a solution (the java libraries shipped with Matlab have to be updated).
Best regards :)
PS: For Ubuntu, there is maybe a solution available, see here https://bugs.launchpad.net/ubuntu/+source/scilab/+bug/1742894
Andrew Cox
le 9 Fév 2018
Réponse acceptée
Plus de réponses (3)
It is a problem caused by the incompatibility of the graphics card driver, I am not gonna explain what the problem is. The simplest and the best solution for me was:
1. Open Matlab
2. Enter "opengl('save','software')"
3. Restart Matlab
It's done
7 commentaires
Moritz Oberjatzas
le 31 Mar 2018
Switching to software rendering did not solve all problems in this case (e.g. plots were not working). Please be aware that the described problem is both
- Linux specific: An update of the mesa library changed the naming behaviour of the renderer
- AMD specific: Only specific AMD graphic cards are affected
It is caused by the really bad way of jogl, the Java OpenGL library, how it tries to find the 3D renderer. The steps above to exchange the MATLAB jogl-library with a fixed version are described above and necessary in this specific case.
And by the way, I did not spend many €€€s for a graphics card just to not use it whenever possible :D
Andrew Cox
le 31 Mar 2018
Tyler Ofstad
le 19 Avr 2018
This worked for me -- thank you!
Walter Roberson
le 2 Mar 2019
Sultan Mehmet KALKANOGLU comments to Kaiyuh:
thank you! it is working.
Levente Környey
le 11 Nov 2020
This is the solution, thank you!
I'm not sure about the solution of Andrew.
Bård Austarå
le 26 Mar 2021
This worked for me, many thanks.
Thad C
le 2 Avr 2018
3 votes
Agreed, changing to OpenGL software rendering is not at all a 'solution'.
Couple updates on the current state of the fix for this error:
- Updates to the functional version of the libjogl2-java package have been accepted into the standard xenial-updates repo (...non-jargony: no longer necessary to add/remove non-standard update source)Updated script here :https://github.com/czuba/sysconfig/raw/master/ubuntuFixJogl_ML2018a.sh
- Unfortunately these jogl errors persist in Matlab 2018a. Hard to imagine releasing a new version knowing it creates a wall of red error text at startup on the most widely used Linux distro out there...
- Notably, the "matlab-support" package necessary to fix other persistent matlab errors on Linux is not currently compatible with Matlab 2018a (as of Mar 28, 2018)
4 commentaires
Royi Avital
le 18 Mai 2018
Hi, For some reason your script doesn't recognize Linux Mint 18.3 as Debian Derivative. Though it can be treated as Ubuntu 16.04. Any idea how to fix this?
Andrew Cox
le 18 Mai 2018
Royi Avital
le 7 Déc 2018
@Andrew, The script of Thad says the official repositories are now updated to have the proper versions.
Any chance you look into it and update the answer (Or add one)?
Royi Avital
le 7 Déc 2018
Modifié(e) : Royi Avital
le 14 Mar 2020
@Thad,
Your script (Which now doesn't add non default repositories) works perfectly on Linux Mint 18.3 with MATLAB R2018b.
On Linux Mint 18.3 the updated libraries are installed from the official repositories.
All I needed to do is remove the lines which checks for Ubuntu.
Thank You.
There's a workaround solution developing on the Psychtoolobx forum in topic 22674: OpenGL problem in Linux
It's a bug in jogl related to detecting the Mesa drivers by string matching for "Gallium" in the glRenderer string, while the Mesa ppl apparently recently implemented a change in how the open-source driver/version is reported. (...or a rough synopsis of this bug report )
Seems like Matlab R2017b might be doing something similarly rudimentary, because my install still seems to be falling back to OpenGL 3.0 (compatibility profile) instead of enabling the full 4.x core version available from my gfx card. ...tbd.
-Thad.
Save the following as a shell script, then execute from terminal in Ubuntu 16.04
(credit to Andreas Widmann's post on the PTB forum for this workaround...I'm just the messenger)
#!/bin/bash
# ubuntuFixJogl2018.sh
# For Ubuntu 16.04 LTS
# Install Psychtoolbox from NeuroDebian, fix jogl install & matlab links
#
# Script based on proposed solution from Andreas Widmann
# for issue reported in:
# https://groups.yahoo.com/neo/groups/PSYCHTOOLBOX/conversations/topics/22674
#
# blame t.b.czuba 2018-02-09
# verify that the computer is running a Debian derivative
if ! command -v dpkg &> /dev/null; then
echo "this script is meant to be run on an Ubuntu system"
exit 1
fi
cd $HOME
# global variables
MATLABROOT="/usr/local/MATLAB/R2017b" # ...update with your Matlab version/location as needed
TOOLROOT="$HOME/MLtoolbox"
echo "you are logged in as user $USER"
echo "matlab toolboxes will be installed in $TOOLROOT"
# configuration
################################################################################
# Add repositories for Psychtoolbox-3 installation (via NeuroDebian)
# - copy-pasta from 'all software' repository for Ubuntu 16.04
# - for different OS options see: http://neuro.debian.net/install_pkg.html?p=matlab-psychtoolbox-3-nonfree
wget -O- http://neuro.debian.net/lists/xenial.us-nh.full | sudo tee /etc/apt/sources.list.d/neurodebian.sources.list
sudo apt-key adv --recv-keys --keyserver hkp://pool.sks-keyservers.net:80 0xA5D32F012649A5A9
sudo apt update
# Install psychtoolbox
sudo apt install -y matlab-psychtoolbox-3-nonfree
# Add directories for Matlab toolboxes
sudo mkdir -v -m 777 "$TOOLROOT"
sudo chown -v "$USER":"$USER" "$TOOLROOT"
# symlink default PTB install location to ~/MLtoolbox
sudo ln -v -s /usr/share/psychtoolbox-3 $TOOLROOT/Psychtoolbox # def PTB location hardcoded by neurodebian
# Fix jogl errors in Matlab (as of Feb 7, 2018)
###################
# (1)
# ADD XENIAL-PROPOSED repository (necessary as of Feb. 2018)
sudo sh -c "echo 'deb http://archive.ubuntu.com/ubuntu/ \
xenial-proposed restricted main multiverse universe' \
> /etc/apt/sources.list.d/xenial-proposed.list"
sudo apt update -y
# ONLY INSTALL THE FOLLOWING from xenial-proposed!
# (...you don't want to upgrade ALL your packages with bleeding-edge versions)
sudo apt install -y libjogl2-java/xenial-proposed
# sudo apt install -y libjogl2-jni/xenial-proposed #...this is included with libjogl2-java in xenial-proposed
# REMOVE XENIAL-PROPOSED repository
sudo rm /etc/apt/sources.list.d/xenial-proposed.list
sudo apt update -y
###################
# (2)
# Change the classpath.txt and librarypath.txt files in $MATLABROOT/toolbox/local.
#
# In classpath.txt find and comment or delete the following two lines (~line 450):
# $MATLABROOT/java/jarext/gluegen-rt.jar
# $MATLABROOT/java/jarext/jogl-all.jar
# and add instead:
# /usr/share/java/jogl2.jar
# /usr/share/java/gluegen2-rt.jar
#
# In librarypath.txt add at the end of the file (incl. a newline):
# /usr/lib/jni
###################
# (3)
# Now it should already work. To be sure that the MATLAB included libraries
# do not interfere I additionally renamed the following libraries in matlabroot/bin/glnxa64:
# libjogl_desktop.so
# libgluegen-rt.so
# libnativewindow_awt.so
# libnativewindow_X11.so
# which are now provided by the packages installed in (1).
cd $MATLABROOT/bin/glnxa64
sudo mv -v ./libjogl_desktop.so ./libjogl_desktop.so.bak
sudo mv -v ./libgluegen-rt.so ./libgluegen-rt.so.bak
sudo mv -v ./libnativewindow_awt.so ./libnativewindow_awt.so.bak
sudo mv -v ./libnativewindow_x11.so ./libnativewindow_x11.so.bak
#
# In matlabroot/toolbox/local/classpath I additionally renamed
# 3p_jogl.jcp
# to be shure it is not added back to classpath in case it is regenerated.
cd $MATLABROOT/toolbox/local/classpath
sudo mv -v ./3p_jogl.jcp ./3p_jogl.jcp.bak
printf "
###################
# PTB install & jogl error fix installed
###################
#
# Must manually apply the following edits w/in your Matlab installation
# To determine path to your \$MATLABROOT, fire up Matlab, then enter
# matlabroot
# in the command window.
#
###################
# Change the classpath.txt and librarypath.txt files in \$MATLABROOT/toolbox/local.
#
# In classpath.txt find and comment or delete the following two lines (~line 450):
# \$MATLABROOT/java/jarext/gluegen-rt.jar
# \$MATLABROOT/java/jarext/jogl-all.jar
# and add instead:
# /usr/share/java/jogl2.jar
# /usr/share/java/gluegen2-rt.jar
#
# In librarypath.txt add at the end of the file (incl. a newline):
# /usr/lib/jni
###################
"
2 commentaires
Andrew Cox
le 9 Fév 2018
Modifié(e) : Andrew Cox
le 31 Mar 2018
Sushen Joshi
le 15 Jan 2019
Hello,
When I tried to do the first step above, after running first 'sudo apt update -y', I got the error in terminal as
E: The repository 'http://archive.ubuntu.com/ubuntu/xenial-proposed restricted Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
Thus, I used the option 'deb [trusted=yes]' instead in the sources.list.d file. After that when I again ran (1st) 'sudo apt update -y', I got the following error and I couldn't go any further.
Any idea how to resolve this? As I am yet to do all the steps to solve the main issue.

Catégories
En savoir plus sur Installation and Operational Settings dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!