필터 지우기
필터 지우기

Cannot enable hardware opengl R2021b Ubuntu 20.04

조회 수: 170 (최근 30일)
Mark Debord
Mark Debord 2021년 10월 7일
답변: Michael Kudenov 2024년 9월 4일
I have a fresh install of Ubuntu 20.04 and matlab 2021b. My machnine has a mobile RTX 3060 gpu and an 11th gen intel processor (system76 gazelle laptop). I have the latest nvidia 470 driver installed. I cannot enable hardware opengl, when I start matlab using a terminal I see this text:
MATLAB is selecting SOFTWARE OPENGL rendering.
Gtk-Message: 16:41:13.106: Failed to load module "canberra-gtk-module"
MESA-LOADER: failed to open iris: /usr/lib/dri/iris_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
failed to load driver: iris
MESA-LOADER: failed to open kms_swrast: /usr/lib/dri/kms_swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
failed to load driver: kms_swrast
MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
failed to load swrast driver
running "opengl info" in matlab returns this:
>> opengl info
Version: '2.1 Mesa 17.1.3'
Vendor: 'Brian Paul'
Renderer: 'Mesa X11'
MaxTextureSize: 16384
Visual: 'Visual 0x290, (RGBA 32 bits (8 8 8 8), Z depth 16 bits, Hardware acceleration, Double buffer, Antialias 0 samples)'
Software: 'true'
HardwareSupportLevel: 'none (known graphics driver issues)'
SupportsGraphicsSmoothing: 0
SupportsDepthPeelTransparency: 1
SupportsAlignVertexCenters: 0
Extensions: {152×1 cell}
MaxFrameBufferSize: 16384
Matlab can see that I have a gpu and I can run gpu operations (ex gpuArray) and generally have no other problems with graphics or cuda. For reference running "gpuDevice" returns this:
>> gpuDevice
ans =
CUDADevice with properties:
Name: 'NVIDIA GeForce RTX 3060 Laptop GPU'
Index: 1
ComputeCapability: '8.6'
SupportsDouble: 1
DriverVersion: 11.4000
ToolkitVersion: 11
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 6.2354e+09
AvailableMemory: 5.9395e+09
MultiprocessorCount: 30
ClockRateKHz: 1425000
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
CanMapHostMemory: 1
DeviceSupported: 1
DeviceAvailable: 1
DeviceSelected: 1
The output of my nvidia-smi
Wed Oct 6 16:53:53 2021
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.63.01 Driver Version: 470.63.01 CUDA Version: 11.4 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... Off | 00000000:01:00.0 Off | N/A |
| N/A 56C P8 14W / N/A | 282MiB / 5946MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 1075 G /usr/lib/xorg/Xorg 4MiB |
| 0 N/A N/A 3836 G /usr/lib/xorg/Xorg 4MiB |
| 0 N/A N/A 34456 C ...R2021b/bin/glnxa64/MATLAB 269MiB |
+-----------------------------------------------------------------------------+
I attempted to force hardware opengl by running "opengl("save","hardware")" and restarting matlab. After doing that and trying "opengl info" again I see this output
opengl info
MATLAB has experienced a low-level graphics error, and may not have drawn correctly.
Read about what you can do to prevent this issue at Resolving Low-Level Graphics Issues then restart MATLAB.
To share details of this issue with MathWorks technical support,
please include this file with your service request.
Version: ''
Vendor: ''
Renderer: 'None'
RendererDriverVersion: ''
RendererDriverReleaseDate: ''
MaxTextureSize: 0
Visual: ''
Software: 0
HardwareSupportLevel: 'full'
SupportsGraphicsSmoothing: 0
SupportsDepthPeelTransparency: 0
SupportsAlignVertexCenters: 0
Extensions: {}
MaxFrameBufferSize: 0
com.jogamp.opengl.GLException: X11GLXDrawableFactory - Could not initialize shared resources for X11GraphicsDevice[type .x11, connection :1, unitID 0, handle 0x0, owner false, ResourceToolkitLock[obj 0x331d5547, isOwner false, <9a81ff0, 27b40220>[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: com.jogamp.opengl.GLException: main-SharedResourceRunner: Unable to create temp OpenGL context(1)
at jogamp.opengl.x11.glx.X11GLXContext.createImpl(X11GLXContext.java:368)
at jogamp.opengl.GLContextImpl.makeCurrentWithinLock(GLContextImpl.java:759)
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:642)
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:580)
at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:297)
... 2 more
The "file" that the error message refers to contains this information:
com.jogamp.opengl.GLException: Profile GL_DEFAULT is not available on X11GraphicsDevice[type .x11, connection :1, unitID 0, handle 0x0, owner false, ResourceToolkitLock[obj 0x331d5547, isOwner false, <9a81ff0, 27b40220>[count 0, qsz 0, owner <NULL>]]], but: []
at com.jogamp.opengl.GLProfile.get(GLProfile.java:990)
at com.jogamp.opengl.GLProfile.getDefault(GLProfile.java:721)
at com.jogamp.opengl.GLCapabilities.<init>(GLCapabilities.java:84)
at com.mathworks.hg.uij.OpenGLUtils$MyGLListener.getGLInformation(OpenGLUtils.java:332)
at com.mathworks.hg.uij.OpenGLUtils$MyGLListener.getGLData(OpenGLUtils.java:512)
at com.mathworks.hg.uij.OpenGLUtils.getGLData(OpenGLUtils.java:79)
I have also tried 2020b with basically the same results. I am pretty stuck at trying to figure out what to do to fix this. Software opengl is incredibly slow and spins up my processor a lot
  댓글 수: 1
Mark Debord
Mark Debord 2021년 10월 7일
편집: Mark Debord 2021년 10월 7일
I have tried to install matlab-support package with apt, and that caused the MESA error messages at launch to go away, but after I launch matlab I still get this error:
com.jogamp.opengl.GLException: X11GLXDrawableFactory - Could not initialize shared resources for X11GraphicsDevice[type .x11, connection :1, unitID 0, handle 0x0, owner false, ResourceToolkitLock[obj 0x158afa41, isOwner false, <36192993, 67a0981a>[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
Unfortunately opengl now does not work at all
opengl info
MATLAB has experienced a low-level graphics error, and may not have drawn correctly.
Read about what you can do to prevent this issue at Resolving Low-Level Graphics Issues then restart MATLAB.
To share details of this issue with MathWorks technical support,
please include this file with your service request.
Version: ''
Vendor: ''
Renderer: 'None'
RendererDriverVersion: ''
RendererDriverReleaseDate: ''
MaxTextureSize: 0
Visual: ''
Software: 0
HardwareSupportLevel: 'full'
SupportsGraphicsSmoothing: 0
SupportsDepthPeelTransparency: 0
SupportsAlignVertexCenters: 0
Extensions: {}
MaxFrameBufferSize: 0
I've tried the 'official' answer here (from 2012!!!) but no progress. I've also tried uninstall-reinstall nvidia driver, and even tried another completely fresh ubuntu install with an older matlab version (2019a) still with the same issues. I feel like I've tried all of the suggestions I've found elsewhere.

댓글을 달려면 로그인하십시오.

채택된 답변

Mark Debord
Mark Debord 2021년 10월 19일
I have recieve official support from matlab with this fix:
Please create a file with the name 'java.opts' in the directory where you execute MATLAB. This file should have a single line:
-Djogl.disable.openglarbcontext=1
I generally launch matlab with a terminal from my home directory, so I placed the 'java.opts' file there and that has resolved this issue. I additionally had to set my preffered X renderer to Nvidia (by default MATLAB was using my onboard IRIS graphics for hardwre opengl). I was able to do this with the power settings icon in the system tray and selecting "Nvidia Graphics" instead of "hybrid". This will affect laptop battery life. Another option would be to change this setting in the nvidia x server settings application under "PRIME profiles"
To recap my setup:
  • Ubuntu 20.04 with proprietary nvidia 470 driver installed an enabled
  • MATLAB R2021b and matlab-support package installed
  • created 'java.opts' file as discussed above
  • enabled Nvidia graphics as system default (NOT hybrid mode, not iGPU mode, must be Nvidia graphics mode)
Thank you to Dennis Henneman from support.
  댓글 수: 5
Christopher Nix
Christopher Nix 2022년 10월 16일
Hello
I am running matlab from the command line on ubuntu 20.04. I am also getting the message
matlab is selecting SOFTWARE OPENGL rendering.
The result is that the matlab environment gui has very tiny script and the graphics windows are so small to be useless. I am not sure if the fix suggested above will work for me, since I do not have an nvidia GPU. Instead I have MESA Intel Graphics (ADL GT2).
Could you let me know which matlab support package I should install and how I should enable the graphics as system default. I have created the java.opts file as mentioned above and this is sitting in my home directory, although the matlab executable is in /usr/local/MATLAB/R2021b/bin
Can you help please?
Thanks
Ivan Graham
Lucija Babic
Lucija Babic 2023년 3월 22일
Thank you, this worked for me too!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Michael Kudenov
Michael Kudenov 2024년 9월 4일
I came across this answer, since I had a similar problem. I did want to keep hybrid mode enabled, though, since fully running Ubuntu on the Nvidia GPU has caused some studdering issues with X11. I am running Ubuntu 24.04, an I9 13900K, and 3090 with the Nvidia 535 drivers. In "Nvidia X Server Settings" under "PRIME Profiles", it is set to "NVIDIA On-Demand". Running Matlab 2024a from the desktop shortcut caused similar issues as in this thread:
>> opengl info
MATLAB has experienced a low-level graphics error, and may not have drawn correctly.
Read about what you can do to prevent this issue at Resolving Low-Level Graphics Issues then restart MATLAB.
To share details of this issue with MathWorks technical support,
please include this file with your service request.
Version: ''
Vendor: ''
Renderer: 'None'
RendererDriverVersion: ''
RendererDriverReleaseDate: ''
MaxTextureSize: 0
Visual: ''
Software: 0
HardwareSupportLevel: 'full'
SupportsGraphicsSmoothing: 0
SupportsDepthPeelTransparency: 0
SupportsAlignVertexCenters: 0
Extensions: {}
MaxFrameBufferSize: 0
However, executing "prime-run matlab" from a terminal yielded the following and enabled graphics to render ok (at least workable):
>> opengl info
Version: '2.1 Mesa 17.1.3'
Vendor: 'Brian Paul'
Renderer: 'Mesa X11'
MaxTextureSize: 16384
Visual: 'Visual 0x20f, (RGBA 32 bits (8 8 8 8), Z depth 16 bits, Hardware acceleration, Double buffer, Antialias 0 samples)'
Software: 'true'
HardwareSupportLevel: 'none (known graphics driver issues)'
SupportsGraphicsSmoothing: 0
SupportsDepthPeelTransparency: 1
SupportsAlignVertexCenters: 0
Extensions: {152×1 cell}
MaxFrameBufferSize: 16384

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by