admin 管理员组

文章数量: 887006

要用深度学习做目标检测,先尝试了caffe,这会又要熟悉tensorflow了,简单写下配置过程吧,挺简单的:

0.win7 X64系统

1.安装vs2013

2.安装Anaconda3(需要里面的python环境)

3.下载CUDA8.0(https://developer.nvidia/cuda-downloads),下面两个exe文件都下载

           补充说明:我电脑里原来是cuda7.5,故需要先卸载干净,我是这么做的,有需要的可以借鉴:

                 (1)把下图中的前5项用电脑管家全部卸载干净(图形驱动程序不需要卸载

             

                 (2)删除C:\Program Files\NVIDIA GPU Computing Toolkit 文件夹

                     删除 C:\ProgramData\NVIDIA GPU Computing Toolkit 文件夹

                     删除C:\ProgramData\NVIDIA Corporation\CUDA Samples 文件夹

4.运行exe(注,若电脑上已经有了最新的显卡驱动程序,可以不用去装图形显卡驱动程序

       

                 默认下一步到最后

5.再运行exe

          

                默认下一步到最后

6.下载cuddn5.1(如果想要了解cuddn和cuda的区别可以看该博客http://blog.csdn/fangjin_kl/article/details/53906874

7.解压cuddn5.1,把如下的三个文件夹替换到C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0夹下(该目录是我的cuda8.0的安装目录)

 这里需要在系统变量里设置下面几个变量:

   CUDA_PATH:          C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0

   CUDA_BIN_PATH: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin

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

   CUDA_PATH_V8_0: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0

   CUDA_SDK_BIN_PATH: C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\bin\win64

   CUDA_SDK_LIB_PATH: C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\common\lib\x64

   CUDA_SDK_PATH:         C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0

8.查看cuda8.0是否安装成功,可以在CMD窗口下敲指令nvcc -V

9.再运行一个Sample例子 打开C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\1_Utilities\deviceQuery解决方案,编译下,出来的结果为

        补充说明:到这说明cuda的环境基本配好了,该笔记本也是支持GPU加速的,可以玩tensorflow gpu版的了

                           中间我报过这个问题,发现是我的显卡驱动被卸载了,设备管理器找不到了

   10.pip安装tensorflow gpu库(http://blog.csdn/u014365862/article/details/53868578)

         在Anaconda Prompt里输入(不是cmd跳出的窗口内输入) pip install tensorflow-gpu==1.2.0(如果直接不加版本限制,会是最新版,此时可能和你的cuda版本有冲突,而报错,所以做好加上版本控制)

      

11.安装完后输入import tensorflow试试

13.我的独立显卡是  

       NVIDIA GeForce 830M, 是可以支持GPU加速的(大家有配不了的时候,别着急,好好分析下原因)

14.提醒下:    

     显卡驱动请用驱动精灵升级到最新版,不然可能会报如下错误:   CUDA driver version is insufficient for CUDA runtime version

15.打开Pycharm,输入

 
 
# python 3.5.3 import tensorflow as tf a = tf.constant([1.0, 2.0, 3.0], shape=[3], name='a') b = tf.constant([1.0, 2.0, 3.0], shape=[3], name='b') c = a + b sess = tf.Session(config = tf.ConfigProto(log_device_placement=True)) print(sess.run(c))
 
 
 
 

 
 

结果:

"C:\Program Files\Anaconda3\python.exe" C:/Users/icecream.shao/Desktop/tensorflow-fcn-master1/ceshi.py
2017-07-30 11:14:08.516152: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.
2017-07-30 11:14:08.516152: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-30 11:14:08.516152: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-30 11:14:08.517152: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard: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-07-30 11:14:08.517152: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard: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-07-30 11:14:08.517152: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard: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-07-30 11:14:08.517152: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard: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-07-30 11:14:08.517152: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard: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-07-30 11:14:09.028203: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\gpu\gpu_device:940] Found device 0 with properties: 
name: GeForce 830M
major: 5 minor: 0 memoryClockRate (GHz) 1.15
pciBusID 0000:03:00.0
Total memory: 2.00GiB
Free memory: 1.94GiB
2017-07-30 11:14:09.028203: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\gpu\gpu_device:961] DMA: 0 
2017-07-30 11:14:09.028203: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\gpu\gpu_device:971] 0:   Y 
2017-07-30 11:14:09.028203: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\gpu\gpu_device:1030] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce 830M, pci bus id: 0000:03:00.0)
2017-07-30 11:14:09.216222: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\direct_session:265] Device mapping:
/job:localhost/replica:0/task:0/gpu:0 -> device: 0, name: GeForce 830M, pci bus id: 0000:03:00.0

Device mapping:
/job:localhost/replica:0/task:0/gpu:0 -> device: 0, name: GeForce 830M, pci bus id: 0000:03:00.0
add: (Add): /job:localhost/replica:0/task:0/gpu:0
b: (Const): /job:localhost/replica:0/task:0/gpu:0
a: (Const): /job:localhost/replica:0/task:0/gpu:0
2017-07-30 11:14:09.219222: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\simple_placer:847] add: (Add)/job:localhost/replica:0/task:0/gpu:0
2017-07-30 11:14:09.219222: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\simple_placer:847] b: (Const)/job:localhost/replica:0/task:0/gpu:0
2017-07-30 11:14:09.219222: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\simple_placer:847] a: (Const)/job:localhost/replica:0/task:0/gpu:0
[ 2.  4.  6.]

Process finished with exit code 0
 
 
 
 
 
 
 
 

本文标签: TensorFlow GPU