首页 » Windows » windows7下使用GPU训练tensorflow深度学习模型

windows7下使用GPU训练tensorflow深度学习模型

原文 http://blog.csdn.net/baidu_15113429/article/details/78678159

2017-12-01 02:01:48阅读(555)

windows7先看一下自己有没有GPU,计算机->属性->设备管理器->显示适配器看到自己的显卡,然后查看是否支持GPU运算。
如果支持GPU运算就可以安装CUDA
tensorflow1.3需要cuda8+cudann8+v6.0+GPU版tensorslow
下载cuda8之后安装,解压cudann8把cudann8中的三个文件
bin,include,lib下面的文件不是文件夹拷贝到C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0对应的文件夹下面。
配置环境变量

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64;

然后在控制面板更改使用有GPU的显卡,重启电脑。
测试代码

#-*- coding:utf8 -*-
# python
import os
import tensorflow as tf
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
with tf.device('/gpu:0'):
    sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
    print(sess.run(c))

测试结果:

C:\python35\python.exe C:/Users/User/PycharmProjects/nlpdemo/tensorflowlearn/cudalearn.py
2017-11-30 15:43:50.576800: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
2017-11-30 15:43:50.766800: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:1030] Found device 0 with properties: 
name: GeForce 920MX major: 5 minor: 0 memoryClockRate(GHz): 0.993
pciBusID: 0000:01:00.0
totalMemory: 2.00GiB freeMemory: 1.94GiB
2017-11-30 15:43:50.766800: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce 920MX, pci bus id: 0000:01:00.0, compute capability: 5.0)
2017-11-30 15:43:50.944800: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\direct_session.cc:299] Device mapping:
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: GeForce 920MX, pci bus id: 0000:01:00.0, compute capability: 5.0
2017-11-30 15:43:50.946800: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\placer.cc:874] MatMul: (MatMul)/job:localhost/replica:0/task:0/device:GPU:0
2017-11-30 15:43:50.946800: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\placer.cc:874] b: (Const)/job:localhost/replica:0/task:0/device:GPU:0
2017-11-30 15:43:50.946800: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\placer.cc:874] a: (Const)/job:localhost/replica:0/task:0/device:GPU:0
Device mapping:
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: GeForce 920MX, pci bus id: 0000:01:00.0, compute capability: 5.0
MatMul: (MatMul): /job:localhost/replica:0/task:0/device:GPU:0
b: (Const): /job:localhost/replica:0/task:0/device:GPU:0
a: (Const): /job:localhost/replica:0/task:0/device:GPU:0
[[ 22.  28.]
 [ 49.  64.]]
Process finished with exit code 0

最新发布

CentOS专题

关于本站

5ibc.net旗下博客站精品博文小部分原创、大部分从互联网收集整理。尊重作者版权、传播精品博文,让更多编程爱好者知晓!

小提示

按 Ctrl+D 键,
把本文加入收藏夹