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

网友投稿 1228 2022-08-23

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

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

安装好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$ pythonPython 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> import tensorflowTraceback (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 directoryFailed to load the native TensorFlow runtime.See some common reasons and solutions. Include the entire stack traceabove 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 zero2017-10-10 17:44:46.548007: I tensorflow/core/common_runtime/gpu/gpu_device.cc:955] Found device 0 with properties: name: GeForce GTX 1070major: 6 minor: 1 memoryClockRate (GHz) 1.683pciBusID 0000:01:00.0Total memory: 7.92GiBFree memory: 7.43GiB2017-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 file or directory.

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:读书笔记:Spark构建分类模型 上
下一篇:SSD Tensorflow:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start
相关文章

 发表评论

暂时没有评论,来抢沙发吧~