Cannot load `swrast` and `iris` drivers in Fedora 35
Asked Answered
F

4

28

Essentially, trying to write the following code results in the error below:

Code

from matplotlib import pyplot as plt
plt.plot([1,2,3,2,1])
plt.show()

Error

libGL error: MESA-LOADER: failed to open iris: /home/xxx/.conda/envs/stat/lib/python3.8/site-packages/pandas/_libs/window/../../../../../libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /usr/lib64/dri/iris_dri.so) (search paths /usr/lib64/dri, suffix _dri)
libGL error: failed to load driver: iris
libGL error: MESA-LOADER: failed to open swrast: /home/xxx/.conda/envs/stat/lib/python3.8/site-packages/pandas/_libs/window/../../../../../libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /usr/lib64/dri/swrast_dri.so) (search paths /usr/lib64/dri, suffix _dri)
libGL error: failed to load driver: swrast

I found similar errors on StackOverflow but none were what is needed here.

Facelifting answered 6/2, 2022 at 18:29 Comment(0)
F
18

Short answer: export LD_PRELOAD=/usr/lib64/libstdc++.so.6

Long answer:

The underlying problem is that we have a piece of software that was built with an older C++ compiler. Part of the compiler is its implementation of libstdc++ which becomes part of the runtime requirements for anything built by the compiler. The software in question has, evidently, brought its own, older implementation of libstdc++ along for the ride, and given its libstdc++ precedence over the system's libstdc++. Typically, this is done via the $LD_LIBRARY_PATH environment variable. Unfortunately, /usr/lib64/dri/swrast_dri.so is a piece of system software built by the native compiler for that system, and it's more recent than the compiler that built the other software in question. The result of this is that the older compiler's libstdc++ gets loaded first, with its older, more limited symbol set. When it then wants to load swrast, this fails because swrast insists on having the level of compiler/runtime with which it was built. The solution to this whole mess is the force the system's (newer) libstdc++ into use and prevent the older libstdc++ from being brought into play. This is achieved via the code snippet export LD_PRELOAD=/usr/lib64/libstdc++.so.6 where we set the preload environment variable.

Facelifting answered 6/2, 2022 at 18:29 Comment(4)
This sounds like it circumvents the actual underlying issue. It sounds more like something is wrong with the conda installation and/or paths that should point to conda directoriesHumanly
@FlyingTeller, if you have suggestions, please feel free to answer the question. Otherwise, this was the best solution I could find comparing to the outrageous ones that others were suggesting online.Facelifting
This did not work for me. I did export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 and am still seeing the error libGL error: failed to load driver: irisMusetta
this is a nice description, but i agree with @adam. I did the suggested bashrc adjustment, but saw no change in behaviour. I assume this i because i'm not running python through my shell terminal, but rather through a terminal in an IDE (pycharm in my case). The condaforge solution seemed to suppress the errors, but to this point, still having trouble plotting.Emogene
S
60

The solution proposed by Mahyar Mirrashed is working for me. On my system (Ubuntu 22.04) the libstdc++.so.6 file is located in /usr/lib/x86_64-linux-gnu/libstdc++.so.6 To know where to find this file I suggest to run the following command :

find / -name libstdc++.so.6 2>/dev/null

which resulted with files from miniconda, snap and /usr/lib/... I added the export LD_PRELOAD to my .bashrc file and it's working fine.

export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6
Someone answered 11/5, 2022 at 12:2 Comment(7)
Thanks. This worked for me. I am running Ubuntu 22.04 LTS.Waadt
Thank you. This worked for me on Linux Mint 21, intel driver with a similar problem.Cooksey
Thanks, it works on mine. As additions, we can also set environment variable when starting conda environment, so we don't need set it manually every time: https://mcmap.net/q/502876/-how-to-set-specific-environment-variables-when-activating-conda-environmentExploitation
This did not work for me. I did export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 and am still seeing the error libGL error: failed to load driver: irisMusetta
@Musetta did the first line that I suggested give you this exact path?Someone
@KevinMarchais what ended up working for me was running conda install -c conda-forge libffi.Musetta
@Cooksey : you just made WinUAE (Amiga Emulator) works again on my old Macbook 2008 with Intel driver (Linux Mint 23). Thank you for your short comment, it really helped!Bastogne
H
35

Installing libstdcxx-ng from conda-forge should solve this problem.

Command:

conda install -c conda-forge libstdcxx-ng
Homeopathy answered 10/3, 2022 at 8:58 Comment(6)
This is probably a good solution and has worked for me some times before. I feel like this might be something that should be reported to the matplotlib team to ensure that this is listed in the requirements.txt for Fedora 35. It would be really annoying to have to run that command every time in every new environment you install matplotlib to.Facelifting
@MahyarMirrashed I agree, but I am not sure how to approach the reporting. Because, as I understand, anaconda packages various projects by itself.Homeopathy
This solved the problem for me. I was having trouble installing vtk in Ubuntu 22.04 inside of a new conda environment.Calcicole
This worked for me without having to try anything else.Izak
Works like a charm!! (tested on kali 2023.1). This solution is quite portable as the dependency can be added to the conda environment. Thus, it will work on my colleges' machines as well.Rayner
Amazing answer ! This worked for me in fixing driver-ralated VTK seg-faults on Ubuntu 22.04Lastminute
F
18

Short answer: export LD_PRELOAD=/usr/lib64/libstdc++.so.6

Long answer:

The underlying problem is that we have a piece of software that was built with an older C++ compiler. Part of the compiler is its implementation of libstdc++ which becomes part of the runtime requirements for anything built by the compiler. The software in question has, evidently, brought its own, older implementation of libstdc++ along for the ride, and given its libstdc++ precedence over the system's libstdc++. Typically, this is done via the $LD_LIBRARY_PATH environment variable. Unfortunately, /usr/lib64/dri/swrast_dri.so is a piece of system software built by the native compiler for that system, and it's more recent than the compiler that built the other software in question. The result of this is that the older compiler's libstdc++ gets loaded first, with its older, more limited symbol set. When it then wants to load swrast, this fails because swrast insists on having the level of compiler/runtime with which it was built. The solution to this whole mess is the force the system's (newer) libstdc++ into use and prevent the older libstdc++ from being brought into play. This is achieved via the code snippet export LD_PRELOAD=/usr/lib64/libstdc++.so.6 where we set the preload environment variable.

Facelifting answered 6/2, 2022 at 18:29 Comment(4)
This sounds like it circumvents the actual underlying issue. It sounds more like something is wrong with the conda installation and/or paths that should point to conda directoriesHumanly
@FlyingTeller, if you have suggestions, please feel free to answer the question. Otherwise, this was the best solution I could find comparing to the outrageous ones that others were suggesting online.Facelifting
This did not work for me. I did export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 and am still seeing the error libGL error: failed to load driver: irisMusetta
this is a nice description, but i agree with @adam. I did the suggested bashrc adjustment, but saw no change in behaviour. I assume this i because i'm not running python through my shell terminal, but rather through a terminal in an IDE (pycharm in my case). The condaforge solution seemed to suppress the errors, but to this point, still having trouble plotting.Emogene
W
1

What worked for me was:

conda install -c conda-forge libffi
Willenewillet answered 12/3 at 10:31 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Electrotechnology

© 2022 - 2024 — McMap. All rights reserved.