Hi!
I am using MATLAB R2021b. Linux Mint 20.2, 5.13.0-21-generic kernel, 11th gen i7-1165G7 CPU.
Software OpenGL failing seems to be a common problem with MATLAB on Linux. I get the following error:
MATLAB is selecting SOFTWARE OPENGL rendering.
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)
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)
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)
failed to load swrast driver
I have tried solution posted here. It worked for me before, but on my new laptop, forcing i965 spits out more errors:
MATLAB is selecting SOFTWARE OPENGL rendering.
gen12 and newer are not supported on i965
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)
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)
failed to load swrast driver
It seems like the previous solution was forcing an older driver (could be totaly wrong here). It seems like this trick does not work with newer CPUs with Intel Xe graphics. Any ideas what to do about this?

 채택된 답변

Dmitrii Turygin
Dmitrii Turygin 2021년 11월 30일
편집: Dmitrii Turygin 2021년 12월 21일

4 개 추천

Okay, I think if figured it out. For whatever reason MATLAB looks in wrong folders for some libraries. You can fix this by pointing MATLAB to them. For my system these are the commands:
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6;
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/dri/;
EDIT: Hm, I think this was not it. MATLAB would load by I would get opengl context erroros right after load. You need to create a java.opts file inside of matlab/bin/glnxa64 folder with -Djogl.disable.openglarbcontext=1 line in it. That should fix the context issue.

댓글 수: 3

Breno
Breno 2022년 2월 16일
편집: Breno 2022년 2월 16일
The export LD_PRELOAD solutions worked like a charm for me on Ubuntu 20.04 with Iris Xe Video card.
A huge thank you for sharing this, it's been 4 months since I've been trying to get MATLAB with hardware mode running on Linux, and with this it finally worked. Thank you!
EDIT: I did had to do something else ir order for it to work properly. Here are the full commands:
export MESA_LOADER_DRIVER_OVERRIDE=i965;
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6;
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/dri/;
These must be run every time I open matlab. One workaround is to put these lines at the end of my ~/.bashrc file (so they are automatically executed at every terminal session), but I'd rather not having those running at every single BASH session, as there's no telling what it might break (but if you're looking for a simple solution, you can do that).
A more complex, yet safer / convenient solution:
Instead of putting the lines at my ~/.bashrc, I opened the matlab launcher file (a .desktop file located in ~/.local/share/applications) and made it run a custom bash script that executes the commands I need and then start matlab.
To do that, you only need to set the line Exec as the path to a custom start bash script. For example, my path would be:
Exec=/path_to_script/matlab-custom-start-script.sh
The bash script itself is as simple as
#!/bin/bash
export MESA_LOADER_DRIVER_OVERRIDE=i965;
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6;
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/dri/;
/path_to_your_matlab/bin/matlab -desktop
Then all there is to do is click on the matlab icon at my launcher bar and voilá.
If you don't have a .desktop file for MATLAB (I hadn't) or want to know more details, here is a good tutorial: https://www.howtogeek.com/445303/how-to-create-desktop-shortcuts-on-ubuntu/
Hope somebody finds use in this!
Chao Wang
Chao Wang 2022년 2월 16일
Thanks! This helps me a lot.
Mayank Kamal
Mayank Kamal 2022년 7월 27일
Thanks!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

릴리스

R2021b

질문:

2021년 11월 30일

댓글:

2022년 7월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by