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

2017-11-30 20:04:56来源:CSDN作者:baidu_15113429人点击

分享

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 -*-# pythonimport osimport tensorflow as tfa = 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.py2017-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 AVX22017-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.993pciBusID: 0000:01:00.0totalMemory: 2.00GiB freeMemory: 1.94GiB2017-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.02017-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:02017-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:02017-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:0Device 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.0MatMul: (MatMul): /job:localhost/replica:0/task:0/device:GPU:0b: (Const): /job:localhost/replica:0/task:0/device:GPU:0a: (Const): /job:localhost/replica:0/task:0/device:GPU:0[[ 22.  28.] [ 49.  64.]]Process finished with exit code 0

相关文章

    无相关信息

最新文章

123

最新摄影

闪念基因

微信扫一扫

第七城市微信公众平台