/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21' not found required by TensorFlow
Asked Answered
G

3

14

I'm trying to deploy a flask app on a debian server using Machine Learning libs, i managed that so far with most ML libraries but i got this error thanks to TensorFlow which i researched a lot about it with no working solution for me.

PS : I'm using a 3.7 python venv for my app

ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /flask/wstest/lib/python3.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so) Mar 01 15:32:11 django gunicorn[8803]: Failed to load the native TensorFlow runtime.

I'm clearly missing the GLIBCXX 3.4.21 because strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXXshows 3.4.20 as the latest version.

Tried this fix add-apt-repository ppa:ubuntu-toolchain-r/test Gives this : result of the toolchain add attempt

Tried apt-get update, Got this

W: Failed to fetch http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu/dists/jessie/main/binary-amd64/Packages 404 Not Found

Also tried to update libgcc and libstdc++6, says i have the latest version.

EDIT : I'm suspecting that Debian 8 Jessie doesn't support a higher glibcxx version than the 3.4.20.

Gaige answered 1/3, 2019 at 16:0 Comment(2)
Are you using TF 1.13.1?Forestaysail
I tried TF 1.13.1 and 1.13.0, couldn't install older versions.Gaige
G
0

So, i just tested Stretch and it works fine. The issue is related to the OS in this case Debian 8 Jessie , it cannot handle a higher version of glibcxxx than the 3.4.20.

PS : Stretch is Debian 9's distribution name

Gaige answered 5/3, 2019 at 11:52 Comment(0)
L
24

Here's a solution for this problem in Ubuntu 16.04

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.9
sudo apt-get upgrade libstdc++6

You can check if you get GLIBCXX desired version like this:

strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX
Leptosome answered 29/4, 2019 at 8:57 Comment(3)
This is a great answer! It is general, is easy to understand and the strings command is a great way to test to see if your problem is the same and also to see if the it has correctly changed after running the apt commands. FYI, I am Ubuntu 20 and sudo apt-get install gcc-4.9 did not work but it was still able to correctly upgrade libstdc++. Thanks!Millikan
Can you explain WHY upgrading libstdc++6 does the trick? I would expect the symbols to be consistent within a given packageAzerbaijani
Also WHY to we need to add ppa:ubuntu-toolchain-r/test? The name sounds experimental, and it feels odd to require an external repository for something as standard as libstdcAzerbaijani
D
8

If you're using Anaconda/Miniconda, you can also get your OS to use the libstdc++.so.6 provided with your installation by setting your LD_LIBRARY_PATH environment variable. Say you have Miniconda installed in /home/whatever/miniconda3 and you're using bash. Then add this to your ~/.bashrc:

export LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu/:/home/whatever/miniconda3/lib

or

export LD_LIBRARY_PATH=/home/whatever/miniconda3/lib

source ~/.bashrc or restart your shell and you should be good to go.

See also: https://gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.how_to_set_paths and How to update libstdc++.so.6 or change the file to use on Tensorflow, Python .

Dendrochronology answered 1/7, 2021 at 13:56 Comment(2)
This answer helped to solve my problem. However, I believe the way the LD_LIBRARY_PATH should be exported is like this: LD_LIBRARY_PATH=$LD_LIBRARY_PATH:... like shown in this answerAddison
did not change anything... error persistsMelar
G
0

So, i just tested Stretch and it works fine. The issue is related to the OS in this case Debian 8 Jessie , it cannot handle a higher version of glibcxxx than the 3.4.20.

PS : Stretch is Debian 9's distribution name

Gaige answered 5/3, 2019 at 11:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.