我尝试过cuda 9但是tensorflow似乎没有用。现在,我安装了cuda 8,设置环境变量和其他一堆东西,但仍然存在此错误。救救我!
>>> import tensorflow as tf
Traceback (most recent call last):
File "/home/nishantsikri/Downloads/tensorflow-dev/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/nishantsikri/Downloads/tensorflow-dev/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/nishantsikri/Downloads/tensorflow-dev/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/usr/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/nishantsikri/Downloads/tensorflow-dev/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/nishantsikri/Downloads/tensorflow-dev/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/nishantsikri/Downloads/tensorflow-dev/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/nishantsikri/Downloads/tensorflow-dev/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/nishantsikri/Downloads/tensorflow-dev/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/nishantsikri/Downloads/tensorflow-dev/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/usr/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems for some common reasons and solutions. Include the entire stack trace above this error message when asking for help.
答案 0 :(得分:0)
在系统中查找libcublas.so.9.0,可能在/usr/local/cuda-9.0/lib64
下。现在添加到您的~/.bashrc
文件:
export LD_LIBRARY_PATH=/path/to/cuda/lib64
然后,您应该继续执行该错误,并查看无法找到libcudnn.so
的错误。确保您已安装CUDNN库并按照libcudnn.so
的相同步骤(libcudnn的实际名称类似于libcudnn.so.7,具体取决于您的版本)。
此处的关键是正确设置LD_LIBRARY_PATH
。
如果问题仍然存在,请确保重新启动终端会话并输入echo $LD_LIBRARY_PATH
以验证是否已正确应用所有设置更改。