争怎路由网:是一个主要分享无线路由器安装设置经验的网站,汇总WiFi常见问题的解决方法。

ubuntu16.04 tensorflow-gpu版本安装好后,容易的检测代码

时间:2024/7/9作者:未知来源:争怎路由网人气:

安装好cuda和 cudnn以后,我们用pip命令安装tensorflow-gpu版本(ubuntu 16.04):
sudo pip install tensorflow-gpu
 
如果是安装的tensorflow 1.3版本,那就要注意了,需要安装cuda 8.0和cudnn 6.0(重要),否则会报错:
xyxt@xyxt-System-Product-Name:~/Downloads/shangyixing$ python  
Python 2.7.12 (default, Nov 19 2016, 06:48:10)   
[GCC 5.4.0 20160609] on linux2  
Type"help","copyright","credits" or"license" for more information.  
>>> import tensorflow  
Traceback (most recent call last):  
File"", line 1, in  
File"/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 24, in  
from tensorflow.python import *  
File"/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 49, in  
from tensorflow.python import pywrap_tensorflow  
File"/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in  
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  
from tensorflow.python.pywrap_tensorflow_internal import *  
File"/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in  
_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: libcudnn.so.6: 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.
 
我们在检测tensorflow-gpu版本是否安装好,需要运行一个python代码进行测试,在python终端输入:
import tensorflow 
>>> import tensorflow as tf  
>>> matrix1 = tf.constant([[3., 3.]])   
>>> matrix2 = tf.constant([[2.],[2.]])  
>>> product = tf.matmul(matrix1, matrix2)   
>>> sess = tf.Session()
 
输出的信息,如果有你的显卡信息,则说明你的tensorflow GPU 版本安装成功了。
2017-10-10 17:44:46.428528: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.  
2017-10-10 17:44:46.428544: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.  
2017-10-10 17:44:46.428549: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.  
2017-10-10 17:44:46.428553: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.  
2017-10-10 17:44:46.428557: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.  
2017-10-10 17:44:46.547766: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:893] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero  
2017-10-10 17:44:46.548007: I tensorflow/core/common_runtime/gpu/gpu_device.cc:955] Found device 0 with properties:   
name: GeForce GTX 1070  
major: 6 minor: 1 memoryClockRate (GHz) 1.683  
pciBusID 0000:01:00.0  
Total memory: 7.92GiB  
Free memory: 7.43GiB  
2017-10-10 17:44:46.548020: I tensorflow/core/common_runtime/gpu/gpu_device.cc:976] DMA: 0   
2017-10-10 17:44:46.548024: I tensorflow/core/common_runtime/gpu/gpu_device.cc:986] 0:   Y   
2017-10-10 17:44:46.548029: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0)
 
参考文献
[1].【报错】ImportError: libcudnn.so.6: cannot open shared object file: No such 今更新了TensorFlow 1.3,结果运行时报ImportError: libcudnn.so.6: cannot open shared object file: No such file or directory
看了更新日志发现,1.3版本需要cuDNN v6.0做支持了,之前是5.1,于是去Nvidia官网下载cuDNN v6.0对应的系统版本安装就好了。


关键词:ubuntu16.04 tensorflow-gpu版本安装好后,容易的检测代码




Copyright © 2012-2018 争怎路由网(http://www.zhengzen.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版