Hardware OpenGL Failure on Ubuntu 16.04.3 - Can not initialize shared resources
22 次查看(过去 30 天)
显示 更早的评论
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 个评论
Moritz Oberjatzas
2018-2-7
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
2018-2-9
编辑:Andrew Cox
2020-5-5
2 个评论
jg614
2018-2-10
编辑:jg614
2018-2-10
Making these changes on Fedora 27 results in an error:
Exception in thread "Startup Class Loader" java.lang.NoClassDefFoundError: com/jogamp/opengl/GLException
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)
Caused by: java.lang.ClassNotFoundException: com.jogamp.opengl.GLException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more
Additionally, for the benefit of anyone else reading this, the required package for Fedora is jogl2 from the rawhide repository. The stable version is not recent enough currently. You will need to download the source package and use rpmbuild --rebuild to build the package for a stable version of Fedora. It will probably give you an error the first time you try to rebuild it, just install the packages listed using dnf and it should compile fine.
About the exception message, can anyone figure out what's wrong? Plotting fails with another error
Caught unexpected fl::except::IInternalException
Edit: I double checked and realized I actually didn't have the .jar files in my /usr/share directory. After copying the .jar files from their correct directories, I get
Warning: librarypath.txt in the startup directory no longer supported. See The Static Path.
Exception in thread "Startup Class Loader" java.lang.UnsupportedClassVersionError: com/jogamp/opengl/GLException : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
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)
I also get this error if I change the paths in classpath.txt to the original paths of the .jar files.
Royi Avital
2018-12-7
编辑:Royi Avital
2020-3-14
It seems the packages rolled (See Thad's script in GitHub).
更多回答(3 个)
Thad C
2018-4-2
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 个评论
Royi Avital
2018-12-7
@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
2018-12-7
编辑:Royi Avital
2020-3-14
@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.
Thad C
2018-2-9
编辑:Thad C
2018-2-9
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 个评论
Sushen Joshi
2019-1-15
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.
![Screenshot from 2019-01-15 02-04-08_modified.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/200745/Screenshot%20from%202019-01-15%2002-04-08_modified.png)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!