11

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.

Blenzus
  • 218
  • 1
  • 2
  • 8

3 Answers3

21

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
Ramineni Ravi Teja
  • 3,568
  • 26
  • 37
  • 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! – ojunk Jan 24 '23 at 14:09
6

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 .

thunder
  • 93
  • 6
dmn
  • 965
  • 3
  • 13
  • 24
  • 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 [answer](https://stackoverflow.com/a/37558191/8488985) – MuadDev Nov 15 '21 at 10:43
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

Blenzus
  • 218
  • 1
  • 2
  • 8