5

I'm using Ubuntu 16.04, Cuda 8.0 and cudann-v5.1. I uninstalled Tensorflow-CPU version and reinstalled tensorflow-GPU enabled. Followed the instructions given here: https://alliseesolutions.wordpress.com/2016/09/08/install-gpu-tensorflow-from-sources-w-ubuntu-16-04-and-cuda-8-0-rc/

However, when I try to load tensorflow, I get the following error:

>>> import tensorflow as tf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 51, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 56, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libnvidia-fatbinaryloader.so.375.39: cannot open shared object file: No such file or directory


Failed to load the native TensorFlow runtime.
James
  • 32,991
  • 4
  • 47
  • 70
Gautham Vasan
  • 51
  • 1
  • 1
  • 2
  • Same problem here. So far I've passed that error message by adding `/usr/lib/nvidia-375` to my `LD_LIBRARY_PATH` environment variable. That's probably not the end of issues though, I'm battling another one right after it that's unresolved. – David Parks Apr 04 '17 at 22:49

6 Answers6

14

I encountered this issue as well, there were two issues that needed to be resolved.

  1. I added /usr/lib/nvidia-375 to my LD_LIBRARY_PATH environment variable. You can verify that the file libnvidia-fatbinaryloader.so.375.39 lives in that directory. If not, find where it does live and add that path. It's not clear to me why this wasn't picked up properly in compiling the sources.

  2. Next I encountered the error:

    libstdc++.so.6: version `CXXABI_1.3.8' not found
    

If you encounter that it's because you have a newer version of gcc than is available in anaconda or your python installation. For me that meant adding this path to LD_LIBRARY_PATH: /usr/lib/x86_64-linux-gnu/libstdc++.so.6

I also had to rename the old libstdc++.so.6 at the path shown in the error message. I couldn't find a way to convince python not to look in the default path without just renaming the file. There may be a cleaner way to do this, but that worked for me.

There were a lot of hidden gotchas in the installation.

David Parks
  • 30,789
  • 47
  • 185
  • 328
  • had the same problem with `LD_LIBRARY_PATH`, thanks I wouldn't have thought about something like this – user3085931 Apr 15 '17 at 12:16
  • Hi, @David Parks, I have libnvidia-fatbinaryloader.so.375.66 in `/usr/lib/nvidia-375` path, but I getting the error as `ImportError: libnvidia-fatbinaryloader.so.375.39: cannot open shared object file: No such file or directory`. What to do? – Akhilesh Aug 02 '17 at 15:13
  • @Akhilesh is it on the PATH or the LD_LIBRARY_PATH? Adding it to your PATH won't help. – David Parks Aug 02 '17 at 15:58
  • Yes @David Parks, that's why I am asking what should I do. By the way, I have solved it temporarily, I don't know the way is correct or not but I have fixed it by `sudo ln -s /usr/lib/nvidia-375/libnvidia-fatbinaryloader.so.375.66 /usr/lib/nvidia-375/libnvidia-fatbinaryloader.so.375.39`. And now it is working. – Akhilesh Aug 03 '17 at 10:37
  • From what you say I'm not convinced that the environment variables are set up correctly. Can you do `echo $LD_LIBRARY_PATH` and verify that you see `/usr/lib/nvidia-375/libnvidia-fatbinaryloader.so.375.66`? I wouldn't be surprised to find that the `.39` version *is* on your LD_LIBRARY_PATH, but the `.66` version is not. – David Parks Aug 04 '17 at 01:36
  • Thanks @David Parks the first step solved my problem. – causation Jan 16 '18 at 16:27
6

In my case tensorflow-gpu was installed and working for a time, but installation of nvidia-opencl-icd-384 caused apt to upgrade my nvidia drivers from 384.47 to 384.59 but did NOT upgrade libcuda, nvidia-settings, and perhaps other packages. Upgrading libcuda should most likely solve the issue but probably best to purge and reinstall.

sudo apt-get purge nvidia*
sudo apt-get install libcuda1-384 nvidia-384 nvidia-384-dev nvidia-prime nvidia-settings

For me, symbolic link for libnvidia-fatbinaryloader.so.384.37 -> libnvidia-fatbinaryloader.so.384.59 in /usr/lib and /usr/lib32 did not correct the issue and LD_LIBRARY_PATH was already correctly configured.

lucidMonkey
  • 404
  • 4
  • 11
1

I encountered the same problem. Here is my solution!

  1. find libnvidia-fatbinaryloader.so.* file in you computer. For me

    (ubuntu16.04):sudo find -iname libnvidia-fatbinaryloader.so*

and then it shows libnvidia-fatbinaryloader.so.375.45,
NOTE:has different version number

  1. copy the file to you cuda lib,e.g:/usr/local/cuda/lib64/

  2. change the version number 375.45 to your missing file , 375.39,e.g:

    mv libnvidia-fatbinaryloader.so.375.45 libnvidia-fatbinaryloader.so.375.39

taras
  • 6,566
  • 10
  • 39
  • 50
1

In my case I previously had nvidia 387.34 and later uninstalled it using

sudo apt-get purge nvidia*

Then I installed driver 384.111, added /usr/lib/nvidia-384 to my LD_LIBRARY_PATH but tensorflow was still asking for libnvidia-fatbinaryloader.so.387.34

I realized that /usr/lib/x86_64-linux-gnu and /usr/lib/i386-linux-gnu still had libcuda.so.387.34 Once I deleted these files from both these directories tensorflow picked up the correct version of 384.

Do apt-get remove nvidia-{{version}} for uninstalling. Then do sudo apt-get purge nvidia*. This will be more foolproof I guess.

0

@Akhilesh has the right answer:

sudo ln -s /usr/lib/nvidia-375/libnvidia-fatbinaryloader.so.375.66 /usr/lib/nvidia-375/libnvidia-fatbinaryloader.so.375.39
kingaj
  • 611
  • 6
  • 13
-1

NOTE: TensorFlow requires MSVCP140.DLL, which may not be installed on your system. If, when you import tensorflow as tf, you see an error about No module named "_pywrap_tensorflow" and/or DLL load failed, check whether MSVCP140.DLL is in your %PATH% and, if not, you should install the [Visual C++ 2015 redistributable (x64 version).[1]: https://www.microsoft.com/en-us/download/details.aspx?id=53587

I recommend you look at the tensorflow's official documentation

I'm sorry I did not see you using Ubuntu I used the Windows10 is so sorry

copie
  • 136
  • 3