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:
Version: '2.1 Mesa 17.1.3'
Visual: 'Visual 0x290, (RGBA 32 bits (8 8 8 8), Z depth 16 bits, Hardware acceleration, Double buffer, Antialias 0 samples)'
HardwareSupportLevel: 'none (known graphics driver issues)'
SupportsGraphicsSmoothing: 0
SupportsDepthPeelTransparency: 1
SupportsAlignVertexCenters: 0
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:
CUDADevice with properties:
Name: 'NVIDIA GeForce RTX 3060 Laptop GPU'
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
AvailableMemory: 5.9395e+09
KernelExecutionTimeout: 1
The output of my nvidia-smi
+-----------------------------------------------------------------------------+
| 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. |
|===============================+======================+======================|
| N/A 56C P8 14W / N/A | 282MiB / 5946MiB | 0
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| GPU GI CI PID Type Process name GPU Memory |
|=============================================================================|
| 0 N/A N/A 1075 G /usr/lib/xorg/Xorg 4MiB |
| 0 N/A N/A 3836 G /usr/lib/xorg/Xorg 4MiB |
+-----------------------------------------------------------------------------+
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
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.
RendererDriverVersion: ''
RendererDriverReleaseDate: ''
HardwareSupportLevel: 'full'
SupportsGraphicsSmoothing: 0
SupportsDepthPeelTransparency: 0
SupportsAlignVertexCenters: 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)
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