1.配置環境
1. 本文在windows7+vs2013的環境下編譯 ,CUDA版本8.0,cudnn版本5.1
2. CUDA下載地址:https://developer.nvidia.com/cuda-toolkit,cudnn:cudnn-8.0-windows7-x64-v5.1 下載地址:https://developer.nvidia.com/cudnn
3. 安裝CUDA8.0(需要在安裝vs2013之後)
4. 解壓下載的cudnn壓縮包,將檔案分別拷貝到CUDA檔案夾下的include、bin和lib目錄下 2.編譯GPU版本的SSD
1. 接上次編譯成功的CPU版本,配置CommonSettings.props
[html] view plain copy <CpuOnlyBuild>false</CpuOnlyBuild> <UseCuDNN>true</UseCuDNN> <CudaVersion>8.0</CudaVersion> 另外,我的cudaarchitecture如下:
[html] view plain copy <CudaArchitecture>compute_35,sm_35;compute_52,sm_52</CudaArchitecture>
2. 編譯libcaffe, 報錯:Dtype expval = exp(min(in_data[index], Dtype(kBNLL_THRESHOLD)));修改bnll_layer.cu如下: [html] view plain copy Dtype expval = exp(min(in_data[index], Dtype(52))); Dtype(52)這邊根據自己顯卡的計算能力填寫。
3.在工程的cu目錄下,分別添加layers,solve和util下的所有cu檔案 (layers下除roi_pooling_layer.cu)
4.修改bbox_util.cu,注釋掉所有帶thrust的語句
5.修改detection_output_layer.cu和detection_output_layer.cpp檔案,注釋掉所有regex和rv的語句
[html] view plain copy //boost::regex exp("\"(null|true|false|-?[0-9]+(\\.[0-9]+)?)\"");
[html] view plain copy //std::string rv = boost::regex_replace(ss.str(), exp, "$1"); //outfile << rv.substr(rv.find("["), rv.rfind("]") - rv.find("[")) // << std::endl << "]" << std::endl;
f.修改detection_output_layer.hpp,注釋#include“boost/regex.hpp”
[html] view plain copy //#include <boost/regex.hpp>
6.caffe中與cudnn相關檔案替換
如果當前應用的caffe對應的cudnn代碼是基於cudnnv3或cudnnv4,要升級到cudnnv5,則需要將最新官方caffe中相應cudnn_conv_layer.hpp、cudnn_lcn_layer.hpp、cudnn_lrn_layer.hpp、cudnn_pooling_layer.hpp、cudnn_relu_layer.hpp、cudnn_sigmoid_layer.hpp、cudnn_softmax_layer.hpp、cudnn_tanh_layer.hpp以及它們各自的.cpp和.cu檔案進行替換。
7. caffe中cudnn.h檔案替換
如果當前應用的caffe對應的cudnn代碼是基於cudnnv3或cudnnv4,要升級到cudnnv5,則需要將最新官方caffe中相應util/cudnn.hpp檔案替換。
8. 編譯libcaffe,編譯caffe,編譯classification.