OpenGL Rendering in Matlab R2024b on Ubuntu LTS 24.04 fails: com.jogamp​.opengl.GL​Exception: X11GLXDrawableFactory - Could not initialize shared resources for ...

502 views (last 30 days)
This error message means that 3D accelerated OpenGL rendering does not work. On same hardware R2024a didn't even try OpenGL, so this is a new problem. This applies to R2024b running on Ubuntu LTS 24.04 on at least two different hardware. There are many more reports here of same errors on older Linux distrubitions with older Matlab versions and probably older hardware, with same workarounds. But it would be better if 3D acceleration worked out of the box with R2024b or at least get disabled by default, if there is a problem.
The whole error message is:
com.jogamp.opengl.GLException: X11GLXDrawableFactory - Could not initialize shared resources for X11GraphicsDevice[type .x11, connection :1, unitID 0, handle 0x0, owner false, ResourceToolkitLock[obj 0x134ee3b8, isOwner false, <590c7f9b, 33bfcb35>[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(Thread.java:748)
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
This happens at least on the following Intel GPUs:
  • Intel Corporation WhiskeyLake-U GT2 [UHD Graphics 620]
  • Intel Corporation Raptor Lake-P [Iris Xe Graphics] (rev 04)
A workaround is to disable 3D acceleration with 'matlab -softwareopengl'.
On a laptop which has both Nvidia and Intel GPU Matlab automatically disables 3D acceleration when you attempt to use the Nvidia GPU:
jjaakkol@lx4-fuxi0:~$ __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia matlab
MATLAB is selecting SOFTWARE rendering.
However if you force 3D rendering on the nvidia GPU, it seems to work fine:
jjaakkol@lx4-fuxi0:~$ __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia matlab -nosoftwareopengl -nodesktop
< M A T L A B (R) >
Copyright 1984-2024 The MathWorks, Inc.
R2024b (24.2.0.2712019) 64-bit (glnxa64)
August 22, 2024
To get started, type doc.
For product information, visit www.mathworks.com.
Warning: OpenGL Startup options will be removed in a future release.
>> rendererinfo
ans =
struct with fields:
GraphicsRenderer: 'OpenGL Hardware'
Vendor: 'NVIDIA Corporation'
Version: '4.6.0 NVIDIA 555.42.06'
RendererDevice: 'NVIDIA RTX 2000 Ada Generation Laptop GPU/PCIe/SSE2'
Details: [1x1 struct]
>>
  2 Comments
li yaomeng
li yaomeng on 7 Nov 2024 at 16:07
我似乎找到了这个问题的解决方法,首先使用这个链接中的方法
https://askubuntu.com/questions/1489242/kuubuntu-23-10-glxinfo-opengl-render-not-show-nvidia
然后再使用这个链接中的方法即可
https://blog.csdn.net/symoriaty/article/details/80042133
li yaomeng
li yaomeng on 7 Nov 2024 at 16:16
其实大体思路就是首先确保openGL能够检测到你的独立显卡,然后再在matlab中启用硬件加速

Sign in to comment.

Answers (3)

Himanshu
Himanshu on 4 Oct 2024
Hello,
I see that you are trying to resolve a 3D accelerated OpenGL rendering issue with MATLAB R2024b on Ubuntu LTS 24.04, which didn't occur in MATLAB R2024a.
You can follow the below steps to resolve this issue:
1) Executing the following command in a Linux Shell to start MATLAB. This command instructs MATLAB to only use software OpenGL libraries.
$ matlab -softwareopengl
2) Create a file with the name 'java.opts' in the directory where MATLAB is executed, containing the line:
-Djogl.disable.openglarbcontext=1
Then start MATLAB and everything should work as expected.
Please refer to the below documentation for more information.
Start MATLAB program from Linux system prompt: https://www.mathworks.com/help/matlab/ref/matlablinux.html
I hope this helps.
  2 Comments
Jani Jaakkola
Jani Jaakkola on 14 Oct 2024
This looks like a AI generated answer. The problem/bug is that 3D accerelation does not work and the flag -softwaregl just disables 3D acceleration, so that Matlab starts.
Yoav
Yoav on 15 Oct 2024
Edited: Yoav on 15 Oct 2024
The 2nd step is a copy of this (Willi Mutschler's) answer, although a bit clearer IMO. When using the linked solution I missed the '-' at the beggining of the fix and it didn't work for me.
Is it possible to amend the old one to be a bit clearer and just link it?

Sign in to comment.


Bilal
Bilal on 7 Nov 2024 at 9:01
Edited: Bilal on 7 Nov 2024 at 9:04
Setting up an environment variable solved the issue and improved the graphics renderer (although softwareopengl fixes the error but produces poor graphics rendering)
In a terminal:
export DRI_PRIME=0
So run matlab in a terminal like:
export DRI_PRIME=0 && ./matlab -desktop &
I have two GPUs: DRI_PRIME=0 implements my iGPU, which is intel's integrated gpu, and DRI_PRIME=1 implements my NVIDIA GPU.
try both value and test it with this command in MATLAB Command Window:
rendererinfo
this is my output:
rendererinfo
ans =
struct with fields:
GraphicsRenderer: 'OpenGL Hardware'
Vendor: 'Intel'
Version: '4.6 (Compatibility Profile) Mesa 24.2.4-1~24.04-tux1'
RendererDevice: 'Mesa Intel(R) Graphics (RPL-S)'
Details: [1×1 struct]

li yaomeng
li yaomeng on 7 Nov 2024 at 16:17
我似乎找到了这个问题的解决方法,首先使用这个链接中的方法
https://askubuntu.com/questions/1489242/kuubuntu-23-10-glxinfo-opengl-render-not-show-nvidia
然后再使用这个链接中的方法即可
其实大体思路就是首先确保openGL能够检测到你的独立显卡,然后再在matlab中启用硬件加速,经过我的测试可以解决这个问题

Categories

Find more on Graphics Performance in Help Center and File Exchange

Products


Release

R2024b

Community Treasure Hunt

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

Start Hunting!