12

I have re-installed Anaconda2. And I got the following error when 'python -c 'import tensorflow''

ImportError: /home/jj/anaconda2/bin/../lib/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /home/jj/anaconda2/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so)

environment

  • CUDA8.0
  • cuDNN 5.1
  • gcc 5.4.1
  • tensorflow r0.10
  • Anaconda2 : 4.2

the following is in bashrc file

  • export PATH="/home/jj/anaconda2/bin:$PATH"
  • export CUDA_HOME=/usr/local/cuda-8.0
  • export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
  • export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
talonmies
  • 70,661
  • 34
  • 192
  • 269
user6918955
  • 121
  • 1
  • 1
  • 4

4 Answers4

29

Seems to be a problem with Anaconda 4.*

You can either update the libgcc package to match your local version

conda update libgcc

but this will require downgrading "due to dependency conflicts" next time you update anaconda.

OR you can mask the anaconda libstdc++ so that your system's libstdc++ is used

cd ~/anaconda2/lib
mv libstdc++.so libstdc++.so.bkp
mv libstdc++.so.6 libstdc++.so.6.bkp

You can further (optionally) create a softlink inside the anaconda lib directly

ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 libstdc++.so.6

These worked for me for the same problem for built-from-source (non-gpu support) tensorflow, Ubuntu 16.04, Anaconda 4.2.0.

Sources: Similar problem to Building TensorFlow from source on Ubuntu 16.04 w/ GPU: `GLIBCXX_3.4.20' not found which also points back to this.

Community
  • 1
  • 1
gevang
  • 4,994
  • 25
  • 33
13

I solved this problem by copying the libstdc++.so.6 file which contains version CXXABI_1.3.8.

Try run the following search command first:

$ strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep CXXABI_1.3.8

If it returns CXXABI_1.3.8. Then you can do the copying.

$ cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /home/jj/anaconda2/bin/../lib/libstdc++.so.6

Xer
  • 493
  • 1
  • 6
  • 17
  • 2
    That doesn't make sense. If your `/usr/lib//` directory has a copy of the shared library with the appropriate ABI, applications that require it should work without you needing to copy that file around. – Kyle Strand Oct 04 '16 at 15:59
  • This helped me! Could you please expand your answer more? –  Jan 21 '17 at 18:43
  • @KyleStrand I understand where you're coming from, but this worked for me in the case where I copied someone else's pre-built binary (https://github.com/mind/wheels). – Keith Sep 15 '17 at 13:55
  • @Keith If the appropriate library is already in `/usr/lib`, it shouldn't matter who built the binary you're trying to run; it takes some deep magic to prevent the runtime linker from finding the correct library if it's already in the system library directory. So if this worked, there's something else afoot. – Kyle Strand Sep 15 '17 at 14:27
  • There's a tensorflow [issue](https://github.com/tensorflow/tensorflow/issues/5017) for this. Note that you're actually copying a link, and not the library. So you could just update the link with the same effect. Don't trying copying the actual library, as that won't work. – orodbhen Feb 03 '18 at 10:50
  • Simply removing the library in Anaconda path will have the same effect. The binary will be able to find the correct library in system packages. ``` mv ~/anaconda2/lib/libstdc++.so ~/anaconda2/lib/libstdc++.so.bkp mv ~/anaconda2/lib/libstdc++.so.6 ~/anaconda2/lib/libstdc++.so.6.bkp ``` – show0k Mar 08 '18 at 15:31
  • this work for me. conda install -c anaconda tensorflow – Humayoo Mar 15 '18 at 02:35
0

I ended up here looking for my problem, same error message but different app.

My app gave the error with /lib64/libstdc++.so.6 which was pointing to /lib64/libstdc++.so.6.0.19

After reading other webs, I kind of figured out I had to "replace" to where my /lib64/libstdc++.so.6 was pointing out and a newer version was located in my conda environment... so:

(sudo) rm /system/path/to/lib/libstdc++.so.6
(sudo) ln -s /path/to/conda/lib/libstdc++.so.6.0.26  /system/path/to/lib/libstdc++.so.6

So I guess it's not the best solution but as user finally get the app works.

Also I read here, this:

Set the LD_LIBRARY_PATH before you run TF, so this lib would only be effective in this shell.

Hope this help.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
0

Typing

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/jj/anaconda2/lib/

in the terminal, will solve the problem.

Hamed Baziyad
  • 1,954
  • 5
  • 27
  • 40
saleh
  • 375
  • 3
  • 8