要用深度學習做目標檢測,先嚐試了caffe,這會又要熟悉tensorflow了,簡單寫下配置過程吧,挺簡單的:
0.win7 X64系統
1.安裝vs2013
2.安裝Anaconda3(需要裏面的python環境)
3.下載CUDA8.0(https://developer.nvidia.com/cuda-downloads),下面兩個exe文件都下載
補充說明:我電腦裏原來是cuda7.5,故需要先卸載乾淨,我是這麼做的,有需要的可以借鑑:
(1)把下圖中的幾項用電腦管家全部卸載乾淨
(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.net/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.net/u014365862/article/details/53868578)
在Anaconda Prompt裏輸入(不是cmd跳出的窗口內輸入) pip install tensorflow-gpu
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.cc: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.cc: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.cc: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.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-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.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-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.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-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.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-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.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-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.cc: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.cc: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.cc: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.cc: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.cc: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.cc: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.cc: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.cc:847] a: (Const)/job:localhost/replica:0/task:0/gpu:0
[ 2. 4. 6.]
Process finished with exit code 0