我正在使用Ubuntu 16.04,Cuda 8.0和cudann-v5.1。我卸载了Tensorflow-CPU版本并重新安装了tensorflow-GPU。按照此处给出的说明进行操作:https://alliseesolutions.wordpress.com/2016/09/08/install-gpu-tensorflow-from-sources-w-ubuntu-16-04-and-cuda-8-0-rc/
但是,当我尝试加载tensorflow时,出现以下错误:
>>> 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.
答案 0 :(得分:14)
我也遇到过这个问题,有两个问题需要解决。
我将/usr/lib/nvidia-375
添加到我的LD_LIBRARY_PATH
环境变量中。您可以验证文件libnvidia-fatbinaryloader.so.375.39
是否存在于该目录中。如果没有,找到它所在的位置并添加该路径。我不清楚为什么在编译源代码时没有正确选择它。
接下来我遇到了错误:
libstdc++.so.6: version `CXXABI_1.3.8' not found
如果你遇到这个问题,那是因为你有一个比anaconda或你的python安装更新版本的gcc。对我而言,这意味着将此路径添加到LD_LIBRARY_PATH
:/usr/lib/x86_64-linux-gnu/libstdc++.so.6
我还必须在错误消息中显示的路径中重命名旧的libstdc++.so.6
。我找不到一种方法来说服python不要在没有重命名文件的情况下查看默认路径。可能有一种更清洁的方法可以做到这一点,但这对我有用。
安装中有很多隐藏的陷阱。
答案 1 :(得分: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.
答案 2 :(得分:1)
我遇到了同样的问题。这是我的解决方案!
在您的计算机中找到libnvidia-fatbinaryloader.so.*
个文件。对我来说
(ubuntu16.04):sudo find -iname libnvidia-fatbinaryloader.so*
然后显示libnvidia-fatbinaryloader.so.375.45
,
注意:具有不同的版本号
将文件复制到您cuda
lib,例如:/usr/local/cuda/lib64/
将版本号375.45
更改为您遗失的文件375.39
,例如:
mv libnvidia-fatbinaryloader.so.375.45 libnvidia-fatbinaryloader.so.375.39
答案 3 :(得分:1)
在我的情况下,我以前使用过nvidia 387.34,然后使用
将其卸载sudo apt-get purge nvidia*
然后我安装了驱动程序384.111,将/usr/lib/nvidia-384
添加到我的LD_LIBRARY_PATH中,但是tensorflow仍然要求libnvidia-fatbinaryloader.so.387.34
我意识到/usr/lib/x86_64-linux-gnu
和/usr/lib/i386-linux-gnu
仍有libcuda.so.387.34
一旦我从这两个目录中删除了这些文件,tensorflow就会选择正确版本的384。
执行apt-get remove nvidia-{{version}}
卸载。然后做sudo apt-get purge nvidia*
。我想这会更加万无一失。
答案 4 :(得分:0)
答案 5 :(得分:-1)
注意:TensorFlow需要MSVCP140.DLL,它可能未安装在您的系统上。如果,当您将tensorflow导入为tf时,您会看到有关No module命名的错误&#34; _pywrap_tensorflow&#34;和/或DLL加载失败,检查MSVCP140.DLL是否在%PATH%中,如果没有,则应安装[Visual C ++ 2015可再发行(x64版本)。[1]:https://www.microsoft.com/en-us/download/details.aspx?id=53587
我建议您查看tensorflow的官方文档
对不起我没有看到你使用Ubuntu我使用的Windows10很抱歉