Windows下caffe安裝詳解 僅CPU

2021-08-26 12:12:46 字數 4478 閱讀 3434

1、環境:windows 7\vs2013

2、caffe-windows準備

圖 4:修改後的commonsettings.props檔案

(2)關於commonsettings.props檔案的一點說明。

<?xml version="1.0" encoding="utf-8"?>  

$(solutiondir)..\build

false

true

7.5

false

false

compute_35,sm_35;compute_52,sm_52

$(solutiondir)\scripts

cublas.lib;cuda.lib;curand.lib;cudart.lib

cudnn.lib;$(cudadependencies)

$(cudnnpath)\cuda\lib\x64;$(librarypath)

$(cudnnpath)\cuda\include;$(includepath)

$(builddir)\$(platform)\$(configuration)\

$(builddir)\int\$(projectname)\$(platform)\$(configuration)\

$(outdir);$(cuda_path)\lib\$(platform);$(librarypath)

$(solutiondir)..\include;$(solutiondir)..\include\caffe\proto;$(cuda_path)\include;$(includepath)

c:\miniconda2\

$(pythondir)\libs;$(librarypath)

$(pythondir)\include;$(includepath)

c:\program files\matlab\r2014b

$(matlabdir)\extern\lib\win64\microsoft;$(librarypath)

$(matlabdir)\extern\include;$(includepath)

cpu_only;%(preprocessordefinitions)

use_cudnn;%(preprocessordefinitions)

use_cudnn

with_python_layer;boost_python_static_lib;%(preprocessordefinitions)

matlab_mex_file;%(preprocessordefinitions)

false

true

_scl_secure_no_warnings;use_opencv;use_leveldb;use_lmdb;%(preprocessordefinitions)

true

full

ndebug;%(preprocessordefinitions)

multithreadeddll

true

true

true

uselinktimecodegeneration

true

disabled

_debug;%(preprocessordefinitions)

multithreadeddebugdll

true

3、編譯caffe-windows

ps:生成時可能遇到的錯誤:errorc2220: 警告被視為錯誤 - 沒有生成「object」檔案 (..\..\src\caffe\util\math_functions.cpp)。這個錯誤可參考sunshine_in_moon 的解決方案。

4、測試

表1:mnist資料集及其檔案解釋

檔案內容

train-images-idx3-ubyte.gz

訓練集 - 55000 張 訓練, 5000 張 驗證

train-labels-idx1-ubyte.gz

訓練集對應的數字標籤

t10k-images-idx3-ubyte.gz

測試集 - 10000 張

t10k-labels-idx1-ubyte.gz

測試集對應的數字標籤

2)轉換 訓練\測試資料

a)  中的四個檔案放到 . \examples\mnist\mnist_data資料夾下。

b)  在caffe-windows安裝的根目錄下,新建乙個convert-mnist-data-train.bat檔案轉換為訓練資料,並在檔案中新增**:

[python]view plain

copy

build\x64\release\convert_mnist_data.exe --backend=lmdbexamples\mnist\mnist_data\train-images.idx3-ubyteexamples\mnist\mnist_data\train-labels.idx1-ubyte examples\mnist\mnist_data\mnist_train_lmdb  

pause  

其中--backend=lmdb 表示轉換為lmdb格式,若要轉換為leveldb將其改寫為--backend=leveldb 即可。

再新建乙個convert-mnist-data-test.bat轉換測試資料,**為:

[python]view plain

copy

build\x64\release\convert_mnist_data.exe --backend=lmdb examples\mnist\mnist_data\t10k-images.idx3-ubyte examples\mnist\mnist_data\t10k-labels.idx1-ubyte examples\mnist\mnist_data\mnist_test_lmdb  

pause  

ps:(1)convert_mnist_data.exe的命令格式為:

convert_mnist_data [flags] input_image_file input_label_file output_db_file

[flags]:轉換的檔案格式可取leveldb或lmdb,示例:--backend=leveldb

output:儲存輸出檔案的資料夾,示例:mnist_train_lmdb

3)執行測試

(1)將第2)步中轉換好的訓練\測試資料集(mnist_train_lmdb\ mnist_train_lmdb或mnist_train_leveldb\mnist_train_leveldb)資料夾放在.\examples\mnist中。

(2)在caffe-windows根目錄下新建乙個run.bat,檔案中**:

[python]view plain

copy

build\x64\release\caffe.exe  train --solver=examples/mnist/lenet_solver.prototxt  

pause  

儲存並雙擊執行,如果執行成功,說明caffe配置成功了。

注意1使用leveldb或lmdb格式的資料時,需要將lenet_train_test.prototxt 檔案裡面的data_param-> source和data_param-> backend相對應,如圖5紅框所標註處。

圖 5:lenet_train_test.prototxt檔案中需要注意與訓練\測試資料對應的部分

注意2將lenet_solver.prototxt 檔案裡面的最後一行改為solver_mode:cpu。

4)訓練自己的資料

1.在caffe上跑自己的資料

2.windows下caffe訓練自己的資料

reference:

官方caffe-windows 配置與示例執行

【caffe-windows】caffe+vs2013+windows無gpu快速配置教程

乙個直接用編譯好的caffe的方法:

windows7 + python3.5 + caffe

關於Windows下安裝caffe

目前只為練手,因此只用cpu練習。配環境。等cpu上面熟練了再練習安裝cuda。先說目前遇到的bug。2.我用的visual studio2013 ultimate版本。3.進入解壓的caffe master commonsettings.props.example重名名為commonsetting...

在Windows系統下安裝caffe

最近,在懟著球面卷積神經網路原始碼看,雖然不出意外的看傻了,但caffe的安裝還是需要記錄一下的。一開始我是想在linux系統下實現的,畢竟一開始我把電腦一大塊空間給了linux系統。於是我先顛顛的照著網上的教程把anaconda先安裝了。anaconda在linux下的安裝 然後我的電腦就開始抽風...

windows下caffe的安裝與配置

根據以上的兩個教程完成了安裝。其中在最後生成解決方案的時候,出現無法鏈結到python 27 檔案按照以下教程解決 但是自己再次回顧的時候,發現出現這個問題的可能原因是缺少了教程中的這個步驟 使用python 安裝以下檔案 conda install yes numpy scipy matplotl...