我有一台运行Ubuntu16.04的linux机器,NVIDIA GEFORCE1060。我正在运行python3.6(使用anaconda安装)和CUDA9.1
我很乐意用CPU编写tensorlow编码,没有任何问题。然后我想安装tensorflow-gpu
以及我遇到问题的地方。
首次成功安装cudnn7.1.2(make
并成功运行mnist-cudnn
)
pip3 install tensorflow_gpu-1.7.0-cp36-cp36m-manylinux1_x86_64.whl
import tensorflow as tf
我收到以下错误
Traceback (most recent call last):
File "/home/bony/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/bony/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/bony/anaconda3/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 "/home/bony/anaconda3/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/home/bony/anaconda3/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/bony/anaconda3/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import * # pylint: disable=redefined-builtin
File "/home/bony/anaconda3/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/bony/anaconda3/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/bony/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/bony/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/bony/anaconda3/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 "/home/bony/anaconda3/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/home/bony/anaconda3/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.
任何帮助解决这个问题并让我继续tensorflow-gpu
将不胜感激
答案 0 :(得分:0)
答案 1 :(得分:0)
首先,在NVIDIA requirements to run TensorFlow with GPU support的官方网页上,我们可以知道:
所以卸载Cuda9.1。
Synaptic Package Manager
,然后在搜索cuda
中选择Mark for complete removal
Synaptic Package Manager
Mark for install
安装cnDNN v7.0
cuDNN v7.0.5 Developer Library for Ubuntu16.04 (Deb)
,因为它是Cuda-9.0的最新版本cuDNN v7.0 安装cuda-command-line-tools
sudo apt-get install cuda-command-line-tools
如果找不到cuda-command-line-tools
sudo apt-cache search cuda-command-line-tool
然后选择安装cuda-command-line-tool-9.0
按照官方文档,将其路径添加到LD_LIBRARY_PATH环境变量
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}/usr/local/cuda/extras/CUPTI/lib64
我正在使用Anaconda3,我使用conda命令创建环境包含py3.5名称py35。
source activate py35
并使用pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.7.0-cp35-cp35m-linux_x86_64.whl
。 您可以选择tensorflow-gpu哪一个支持您的python版本。
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
Hello, TensorFlow!
,那么您就可以开始编写TensorFlow程序。