Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 653
Blenzus Avatar asked Mar 01 '19 16:03

Blenzus


2 Answers

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
like image 120
Ramineni Ravi Teja Avatar answered Oct 24 '22 10:10

Ramineni Ravi Teja


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 .

like image 3
dmn Avatar answered Oct 24 '22 10:10

dmn