Could not initialize shared resources for X11GraphicsDevice

529 views (last 30 days)
Yalun Wen
Yalun Wen on 1 Jun 2017
Commented: Soohyun Cho on 30 Oct 2021
Hey,
I'm using Dell precision 7510 with preinstalled Ubuntu 14.04(I have the driver the NVIDIA). I just downloaded the MATLAB 2017a and I run into the following error. I just searched and found it's not just me who have the same problem. I wonder if this problem is fixable? To put it in another way, could I use all the features provided by MATALB with this error?
Thank you in advance, attached is the error infor
com.jogamp.opengl.GLException: X11GLXDrawableFactory - Could not initialize shared resources for X11GraphicsDevice[type .x11, connection :0, unitID 0, handle 0x0, owner false, ResourceToolkitLock[obj 0x413b9df1, isOwner false, <30fe5aac, af2eb55>[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: com.jogamp.opengl.GLException: glXGetConfig(0x1) failed: error code Unknown error code 6
at jogamp.opengl.x11.glx.X11GLXGraphicsConfiguration.glXGetConfig(X11GLXGraphicsConfiguration.java:570)
at jogamp.opengl.x11.glx.X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(X11GLXGraphicsConfiguration.java:500)
at jogamp.opengl.x11.glx.X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationXVisual(X11GLXGraphicsConfigurationFactory.java:434)
at jogamp.opengl.x11.glx.X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(X11GLXGraphicsConfigurationFactory.java:240)
at jogamp.opengl.x11.glx.X11GLXDrawableFactory.createMutableSurfaceImpl(X11GLXDrawableFactory.java:524)
at jogamp.opengl.x11.glx.X11GLXDrawableFactory.createDummySurfaceImpl(X11GLXDrawableFactory.java:535)
at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:283)
... 2 more

Accepted Answer

Kushagr Gupta
Kushagr Gupta on 9 Jun 2017
This low-level graphics error is an NVIDIA driver issue. If possible, downgrade to a previous NVIDIA driver, such as the one that was on the system before the update.
1. Start MATLAB with nodesktop AND the opengl info command, and then open the desktop. This gets the right library load order for everything to work. Try to start MATLAB with the following command (in the Windows Command Prompt) :
>>matlab -nodesktop -r "opengl info, desktop"
This command starts MATLAB with "nodesktop" and the "opengl info" command, and then opens the desktop. The downside is you cannot start MATLAB in the background, or suspend (Ctrl-Z) and push it to the background (bg).
This might have to be used in conjunction with the "libstdc++.so.6" library being incompatible which can be resolved using the workaround in the following bug report :
2. Downgrade from NVIDIA driver version 367.57 to version 340.98, a stable previous release:
3. Keep an eye out for new NVIDIA drivers on the NVIDIA website:
4. If it is not possible or preferable to change your graphics driver, use MATLAB with Software OpenGL. Open MATLAB from the Linux Terminal with the following command:
$ matlab -softwareopengl
You can set your preferences so that MATLAB always starts with Software OpenGL by executing the following in the MATLAB Command Window:
>> opengl('save','software')
You can always revert to your default graphics renderer with the following:
>> opengl('save','none')
  1 Comment
Cliff Bargar
Cliff Bargar on 27 Aug 2018
Thanks, I'm running MATLAB in an Ubuntu VM and was experiencing this problem. I tried options 1-3 unsuccessfully but option 4 seems to work

Sign in to comment.

More Answers (6)

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
  15 Comments
Soohyun Cho
Soohyun Cho on 30 Oct 2021
I had the same issue with Fedora 34, R2021b, the suggested solution solved the problem.
export MESA_LOADER_DRIVER_OVERRIDE=i965
Below is my video card information from lspci -v:
00:02.0 VGA compatible controller: Intel Corporation WhiskeyLake-U GT2 [UHD Graphics 620] (prog-if 00 [VGA controller])
Subsystem: LG Electronics, Inc. Device 0325

Sign in to comment.


Willi Mutschler
Willi Mutschler on 26 Apr 2020
Edited: 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.

Georg Beyerle
Georg Beyerle on 6 Oct 2018
Same behaviour with R2018b on openSUSE Leap 15 with ATI Radeon HD 5450 graphics card.

Miroslav Flídr
Miroslav Flídr on 19 Apr 2018

The problem is caused by changes in NVIDIA drivers 361.xx and newer and MATLAB reliance on driver behavior outside standard Linux OpenGL ABI (thus it's mainly MathWorks problem). These changes are described here . I could solve the problem by replacing the libGL.so.1.0.0 driver library from the official NVIDIA binary driver installer. First check the version of the driver used in the system, e.g. using nvidia-smi utility. Download the driver https://www.geforce.com/drivers. Then unpack the downloaded driver installer using the --extract-only installer command line switch. Finally replace the installed libGL.so.1.0.0 library file with the libGL.so.$VERSION file from the unpacked installer (the file must be renamed to libGL.so.1.0.0).

I already lost hope that the MathWorks will fix anytime soon this two years old bug.


Christopher Wong
Christopher Wong on 28 Aug 2021
Edited: Christopher Wong on 28 Aug 2021
For AMD GPUs on Ubuntu:
If you're using an AMD graphics card on Ubuntu (or perhaps some other flavor of Linux) and you are having this issue, or if you notice that MATLAB automatically switches to a software implementation of OpenGL, you most likely need to install the amdgpu-pro package, which includes all of the open-sourced drivers, plus a few of the proprietary drivers, mainly Vulkan. The Ubuntu software repositories only maintain a stable release of the amdgpu package, which appears to not provide enough to support MATLAB. I reccomend installing amdgpu-pro. AMD GPUs and drivers are very reliable in Ubuntu OS (much more so than NVIDIA). It's totally safe to install and I've never had any issues.
Set your OpenGL preference to 'none' in MATLAB so that it's automatically determined at the start of each session:
opengl('save', 'none')
Then close MATLAB. Now, go and find the latest AMD drivers for your GPU and OS here and download the tarball. Carefully follow the instructions they provide you to unpack and install the drivers (but don't take too literally their recommendation to use amdgpu-pro with their Pro series GPUs, it works for their consumer products as well, e.g., I have a Radeon RX 5700 XT). I recommend just going with the heaviest pro install option that includes the OpenCL components, i.e., run the installer by the following command:
./amdgpu-pro-install -y --opencl=rocr,legacy
Finally, reboot your system and open MATLAB. The output from the rendererinfo(gca) command should indicate that the renderer is using a hardware-accelerated version of OpenGL.
  1 Comment
Christopher Wong
Christopher Wong on 28 Aug 2021
P.S., I realize my answer isn't 100% focused on the original question (since @Yalun Wen's problem was with an NVIDIA GPU), but I ended up here through the same error key "Could not initialize shared resources for X11GraphicsDevice" and I noticed a few others mentioning AMD/ATI on this thread so I figured I'd drop my solution. None of the solutions posted here worked for me. I simply needed the additional driver components provided by the pro package.

Sign in to comment.


chao yao
chao yao on 15 Jan 2019
I have the same issue with AMD Radeon VEGA 64, the 4th solution in the accepted answer works for me.

Community Treasure Hunt

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

Start Hunting!

Translated by