[英]Tensorflow-gpu installation issue on ubuntu16.04
I have a linux machine running Ubuntu16.04, NVIDIA GEFORCE1060. 我有一台运行Ubuntu16.04,NVIDIA GEFORCE1060的Linux机器。 I am running python3.6 (installed using anaconda) and CUDA9.1 我正在运行python3.6(使用anaconda安装)和CUDA9.1
I was happily coding in tensorlow with CPU with no issues. 我很高兴在Tensorlow中使用CPU进行编码,没有任何问题。 Then I wanted to install tensorflow-gpu
and that's where I am having issues. 然后我想安装tensorflow-gpu
,这就是我遇到的问题。
First installed cudnn7.1.2 successfully ( make
and run mnist-cudnn
completed successfully) 首次成功安装cudnn7.1.2(成功完成make
and run mnist-cudnn
)
pip3 install tensorflow_gpu-1.7.0-cp36-cp36m-manylinux1_x86_64.whl
import tensorflow as tf
I am getting the following errors 我收到以下错误
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.
Any help to resolve this and get me going on tensorflow-gpu
will be appreciated 任何帮助解决此问题并让我继续使用tensorflow-gpu
将不胜感激
First,on the official web page part of NVIDIA requirements to run TensorFlow with GPU support we can know : 首先,在NVIDIA要求的官方网页上, 要运行具有GPU支持的TensorFlow,我们可以知道:
So uninstall Cuda9.1. 因此,请卸载Cuda9.1。
Synaptic Package Manager
in Ubuntu Software,and Search cuda
and select Mark for complete removal
如果您不知道如何卸载,则可以在Ubuntu软件中安装Synaptic Package Manager
,然后搜索cuda
并选择“ Mark for complete removal
Synaptic Package Manager
重新加载Synaptic Package Manager
Mark for install
选择Cuda-9.0 Mark for install
Install cnDNN v7.0 安装cnDNN v7.0
cuDNN v7.0.5 Developer Library for Ubuntu16.04 (Deb)
,because it is the latest version cuDNN v7.0 for Cuda-9.0 我已经下载了cuDNN v7.0.5 Developer Library for Ubuntu16.04 (Deb)
,因为它是Cuda-9.0的最新版本cuDNN v7.0。 Install cuda-command-line-tools
安装cuda-command-line-tools
sudo apt-get install cuda-command-line-tools
If can not find cuda-command-line-tools
如果找不到cuda-command-line-tools
sudo apt-cache search cuda-command-line-tool
And select install cuda-command-line-tool-9.0
然后选择install cuda-command-line-tool-9.0
Follow official document,add its path to your LD_LIBRARY_PATH environment variable 遵循官方文档,将其路径添加到您的LD_LIBRARY_PATH环境变量中
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}/usr/local/cuda/extras/CUPTI/lib64
I am using Anaconda3, i use conda command create environment include py3.5 name py35. 我正在使用Anaconda3,我使用conda命令创建环境,包括py3.5名称py35。
source activate py35
and use pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.7.0-cp35-cp35m-linux_x86_64.whl
. 因此,我使用source activate py35
并使用pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.7.0-cp35-cp35m-linux_x86_64.whl
source activate py35
pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.7.0-cp35-cp35m-linux_x86_64.whl
。 You can select tensorflow-gpu which one support you python version. 您可以选择tensorflow-gpu ,其中一个支持您的python版本。
Validate your installation 验证安装
import tensorflow as tf hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() print(sess.run(hello))
运行一个简短的TensorFlow程序, import tensorflow as tf hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() print(sess.run(hello))
Hello, TensorFlow!
如果系统输出Hello, TensorFlow!
, then you are ready to begin writing TensorFlow programs. ,那么您就可以开始编写TensorFlow程序了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.