Tensorflow安装环境更新
本博文是对前面两篇tensorflow的博文的一个继续,对环境的更新。
基于tensorflow的MNIST手写识别
安装tensorflow,那叫一个坑啊
主要出发点:
上述两篇博文的程序运行的环境,其实是没有用到GPU的。本篇博文,介绍如何利用GPU。
首先通过pip重新安装一个支持gpu的tensorflow,采用upgrade的方式进行。
[root@bogon tensorflow]# pip install --upgrade tensorflow-gpu
Collecting tensorflow-gpu
Downloading tensorflow_gpu-1.0.-cp27-cp27mu-manylinux1_x86_64.whl (.8MB)
% |████████████████████████████████| .8MB .6kB/s
Requirement already up-to-date: protobuf>=3.1. in /usr/lib64/python2./site-packages (from tensorflow-gpu)
Requirement already up-to-date: six>=1.10. in /usr/lib/python2./site-packages (from tensorflow-gpu)
Requirement already up-to-date: wheel in /usr/lib/python2./site-packages (from tensorflow-gpu)
Requirement already up-to-date: mock>=2.0. in /usr/lib/python2./site-packages (from tensorflow-gpu)
Requirement already up-to-date: numpy>=1.11. in /usr/lib64/python2./site-packages (from tensorflow-gpu)
Requirement already up-to-date: setuptools in /usr/lib/python2./site-packages (from protobuf>=3.1.->tensorflow-gpu)
Requirement already up-to-date: funcsigs>=; python_version < "3.3" in /usr/lib/python2./site-packages (from mock>=2.0.->tensorflow-gpu)
Requirement already up-to-date: pbr>=0.11 in /usr/lib/python2./site-packages (from mock>=2.0.->tensorflow-gpu)
Requirement already up-to-date: appdirs>=1.4. in /usr/lib/python2./site-packages (from setuptools->protobuf>=3.1.->tensorflow-gpu)
Requirement already up-to-date: packaging>=16.8 in /usr/lib/python2./site-packages (from setuptools->protobuf>=3.1.->tensorflow-gpu)
Requirement already up-to-date: pyparsing in /usr/lib/python2./site-packages (from packaging>=16.8->setuptools->protobuf>=3.1.->tensorflow-gpu)
Installing collected packages: tensorflow-gpu
Successfully installed tensorflow-gpu-1.0.
这个过程顺利完成。
然后,将MNIST的手写识别程序,在运行一下,验证一下,是否启用GPU。
[root@bogon tensorflow]# python mnist_demo1.py
I tensorflow/stream_executor/dso_loader.cc:] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:126] Couldn't open CUDA library libcudnn.so.5. LD_LIBRARY_PATH: /usr/local/cuda-8.0/lib64:
I tensorflow/stream_executor/cuda/cuda_dnn.cc:3517] Unable to load cuDNN DSO
I tensorflow/stream_executor/dso_loader.cc:] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:] successfully opened CUDA library libcuda.so. locally
I tensorflow/stream_executor/dso_loader.cc:] successfully opened CUDA library libcurand.so.8.0 locally
Extracting MNIST_data/train-images-idx3-ubyte.gz
Extracting MNIST_data/train-labels-idx1-ubyte.gz
Extracting MNIST_data/t10k-images-idx3-ubyte.gz
Extracting MNIST_data/t10k-labels-idx1-ubyte.gz
W tensorflow/core/platform/cpu_feature_guard.cc:] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
I tensorflow/core/common_runtime/gpu/gpu_device.cc:] Found device with properties:
name: GeForce GTX
major: minor: memoryClockRate (GHz) 1.7335
pciBusID ::00.0
Total memory: .92GiB
Free memory: .81GiB
I tensorflow/core/common_runtime/gpu/gpu_device.cc:] DMA:
I tensorflow/core/common_runtime/gpu/gpu_device.cc:] : Y
I tensorflow/core/common_runtime/gpu/gpu_device.cc:] Creating TensorFlow device (/gpu:) -> (device: , name: GeForce GTX , pci bus id: ::00.0)
F tensorflow/stream_executor/cuda/cuda_dnn.cc:] Check failed: s.ok() could not find cudnnCreate in cudnn DSO; dlerror: /usr/lib/python2./site-packages/tensorflow/python/_pywrap_tensorflow.so: undefined symbol: cudnnCreate
Aborted (core dumped)
上面红色部分报错了,找不到cudnn的so文件,进入到cuda的安装路径,查看是否有这个so。
[root@bogon lib64]# ll libcudnn
libcudnn.so.5.1 libcudnn.so.5.1. libcudnn_static.a
的确没有libcudnn.so.5的文件。
下面,建立一个软连接,将libcudnn.so.5指向libcudnn.so.5.1。
[root@bogon lib64]# ln -s libcudnn.so.5.1 libcudnn.so.5
[root@bogon lib64]# ll libcudnn*
lrwxrwxrwx. root root Mar : libcudnn.so. -> libcudnn.so.5.1
lrwxrwxrwx. root root Mar : libcudnn.so.5.1 -> libcudnn.so.5.1.
-rwxr-xr-x. root root Mar : libcudnn.so.5.1.
-rw-r--r--. root root Mar : libcudnn_static.a
现在,有了这个libcudnn.so.5的文件了。
再次验证mnist的手写识别程序。
[root@bogon tensorflow]# python mnist_demo1.py
I tensorflow/stream_executor/dso_loader.cc:] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:] successfully opened CUDA library libcudnn.so. locally
I tensorflow/stream_executor/dso_loader.cc:] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:] successfully opened CUDA library libcuda.so. locally
I tensorflow/stream_executor/dso_loader.cc:] successfully opened CUDA library libcurand.so.8.0 locally
Extracting MNIST_data/train-images-idx3-ubyte.gz
Extracting MNIST_data/train-labels-idx1-ubyte.gz
Extracting MNIST_data/t10k-images-idx3-ubyte.gz
Extracting MNIST_data/t10k-labels-idx1-ubyte.gz
W tensorflow/core/platform/cpu_feature_guard.cc:] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
I tensorflow/core/common_runtime/gpu/gpu_device.cc:] Found device with properties:
name: GeForce GTX
major: minor: memoryClockRate (GHz) 1.7335
pciBusID ::00.0
Total memory: .92GiB
Free memory: .81GiB
I tensorflow/core/common_runtime/gpu/gpu_device.cc:] DMA:
I tensorflow/core/common_runtime/gpu/gpu_device.cc:] : Y
I tensorflow/core/common_runtime/gpu/gpu_device.cc:] Creating TensorFlow device (/gpu:) -> (device: , name: GeForce GTX , pci bus id: ::00.0)
0.9092
到现在为止,我的tensorflow的运行环境,已经是基于GPU的了。
下面附上测试中的mnist_demo1.py的内容:
#!/usr/bin/env python
# -*- coding: utf- -*- import tensorflow as tf import tensorflow.examples.tutorials.mnist.input_data as input_data
mnist = input_data.read_data_sets("MNIST_data", one_hot=True) sess = tf.InteractiveSession() x = tf.placeholder("float", shape=[None, ])
y_ = tf.placeholder("float", shape=[None, ]) w = tf.Variable(tf.zeros([,]))
b = tf.Variable(tf.zeros([])) init = tf.global_variables_initializer()
sess.run(init) y = tf.nn.softmax(tf.matmul(x, w) + b) cross_entropy = -tf.reduce_sum(y_*tf.log(y)) train_step = tf.train.GradientDescentOptimizer(0.01).minimize(cross_entropy) for i in range():
batch = mnist.train.next_batch()
train_step.run(feed_dict={x: batch[], y_: batch[]}) correct_prediction = tf.equal(tf.argmax(y,), tf.argmax(y_,))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float")) print accuracy.eval(feed_dict={x: mnist.test.images, y_: mnist.test.labels})
最后说明下,上述WARNING部分:
W tensorflow/core/platform/cpu_feature_guard.cc:] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
暂时没有关注,所知道的处理办法,就是用bazel进行源码安装tensorflow可以解决这个问题。由于不是太影响实验,暂且不关注。
Tensorflow安装环境更新的更多相关文章
- TensorFlow安装环境的误区
安装py一定要注意安装的版本,我一开始安装的3.7版本的,现在还没有支持,另外,看清楚自己电脑是32位还是64位的
- 【吴恩达课程使用】keras cpu版安装【接】- anaconda (python 3.7) win10安装 tensorflow 1.8 cpu版
一.确认tensorflow的版本: 接上一条tensorflow的安装,注意版本不匹配会出现很多问题!:[吴恩达课程使用]anaconda (python 3.7) win10安装 tensorfl ...
- 深度学习入门篇--手把手教你用 TensorFlow 训练模型
欢迎大家前往腾讯云技术社区,获取更多腾讯海量技术实践干货哦~ 作者:付越 导语 Tensorflow在更新1.0版本之后多了很多新功能,其中放出了很多用tf框架写的深度网络结构(https://git ...
- ArXiv最受欢迎开源深度学习框架榜单:TensorFlow第一,PyTorch第四
[导读]Kears作者François Chollet刚刚在Twitter贴出最近三个月在arXiv提到的深度学习框架,TensorFlow不出意外排名第一,Keras排名第二.随后是Caffe.Py ...
- 【转载】史上最全:TensorFlow 好玩的技术、应用和你不知道的黑科技
[导读]TensorFlow 在 2015 年年底一出现就受到了极大的关注,经过一年多的发展,已经成为了在机器学习.深度学习项目中最受欢迎的框架之一.自发布以来,TensorFlow 不断在完善并增加 ...
- Tensorflow物体检测(Object Detection)API的使用
Tensorflow在更新1.2版本之后多了很多新功能,其中放出了很多用tf框架写的深度网络结构(看这里),大大降低了吾等调包侠的开发难度,无论是fine-tuning还是该网络结构都方便了不少.这里 ...
- Tensorflow & Python3 做神经网络(视频教程)
Tensorflow 简介 1.1 科普: 人工神经网络 VS 生物神经网络 1.2 什么是神经网络 (Neural Network) 1.3 神经网络 梯度下降 1.4 科普: 神经网络的黑盒不黑 ...
- Centos7安装TensorFlow
TensorFlow也火了一段时间,想想既然要研究NLP.为什么不好好应用一下Google开源的Deep Learning平台呢,一切还是先从搭建好开发环境開始. 非常多大神们也做了这方面的工作.汲取 ...
- Tensorflow代码解析(一)
http://www.leiphone.com/news/201702/n0uj58iHaNpW9RJG.html?utm_source=tuicool&utm_medium=referral ...
随机推荐
- 最新2018年三月可用Windows10激活密钥
Windows 10 Edition Product Key Windows 10 Home TX9XD-98N7V-6WMQ6-BX7FG-H8Q99 Windows 10 Home Single ...
- Spring Boot 揭秘与实战(二) 数据缓存篇 - Guava Cache
文章目录 1. Guava Cache 集成 2. 个性化配置 3. 源代码 本文,讲解 Spring Boot 如何集成 Guava Cache,实现缓存. 在阅读「Spring Boot 揭秘与实 ...
- httpd: config error '*.php:/usr/bin/php-cgi' in '/etc/httpd.conf'
/********************************************************************************* * httpd: config e ...
- Project篇:项目1
项目: 步骤: (1)布置项目 (2)独立完成项目设计 (3)项目框架讲解 (4)独立完成项目功能编写 (5)项目讲解 项目内容介绍: 项目开发流程: 需求分析------>概要设计------ ...
- linux shell 中文件编码查看及转换方法
参考: http://edyfox.codecarver.org/html/vim_fileencodings_detection.html 一.查看文件编码. 在打开文件的时候输入:set ...
- P2261 [CQOI2007]余数求和 (数论)
题目链接:传送门 题目: 题目背景 数学题,无背景 题目描述 给出正整数n和k,计算G(n, k)=k mod + k mod + k mod + … + k mod n的值,其中k mod i表示k ...
- 实验吧—隐写术——WP之 SB!SB!SB!
我们先打开解题链接,里面是一张愤怒的小鸟里的小猪~ 既然这是隐写题,那么肯定要把图片下载下来进行分析咯~ 下载下来之后,我们看到题目中提示:LSB 什么是LSB? LSB(Least Signific ...
- 20165313 《Java程序设计》第九周学习总结
教材学习总结 1.URL类 :ava.net包中的URL类是对统一资源定位符的抽象,使用URL创建对象的应用程序称作客户端程序,客户端程序的URL对象调用InputStream openStream( ...
- 重写&重载
重写:子类对父类或接口中方法重新定义,是同一个方法 (1)子类不能重写final方法 (2)子类必须重写abstract方法 重载:一个类内部,方法同名,参数列表不同 (1)返回值不能作为区分重载方法 ...
- springboot配置文件启动顺序
[1]项目内部配置文件 spring boot 启动会扫描以下位置的application.properties或者application.yml文件作为Spring boot的默认配置文件 1.–f ...