使用MDnet時遇到的一些問題(matlab版)


最近使用嘗試使用MDNet做一些tracking問題,作者提供了matlab和python兩種實現

由於python版本需要使用torch,決定先使用matlab版本試一下,然后就踩進了一些坑,以下做一下記錄備忘(

機器配置Ubuntu 16.04 LTS, CPU E5 1620, GPU GTX1080ti, CUDA 8.0

首先編譯matconvnet:

MDNet自帶一個MatConvnet,需要手動編譯,自帶的MakeFile文件不能實現直接編譯,做了一些修改:

  1. 刪除了doc相關的信息:
```
#include doc/MakeFile
clean: #doc-clean
```
  1. 增加GPU支持
```
ENABLE_GPU ?= yes
```
  1. 修改相關引用目錄和信息
```
ARCH ?= glnxa64
MATLABROOT ?= /usr/local/MATLAB/R2017a
CUDAROOT ?= /usr/local/cuda
```
  1. 修改了ARCH后發現glnxa64編譯時會出現 "nvcc fatal : redefinition of argument 'optimize'" 問題,發現是debug默認開啟,優化選項為O,但是glnxa64在makefile中使用了O3優化,因此需要在MakeFile開始處設置:
```
DEBUG?= no
```
  1. 至此可使用make進行編譯
  2. 關於使用cudnn
 在編譯的時候嘗試使用過cudnn6,但是發現似乎不支持,官網上也只說支持cudnn2和4,如果之后有需求,再進行更新,錯誤如下:


```
matlab/src/bits/impl/nnconv_cudnn.cu:112: error: argument of type "int" is incompatible with parameter of type "cudnnTensorFormat_t"

matlab/src/bits/impl/nnconv_cudnn.cu:112: error: too few arguments in function call

matlab/src/bits/impl/nnconv_cudnn.cu:134: error: too few arguments in function call

matlab/src/bits/impl/nnconv_cudnn.cu:207: error: identifier "CUDNN_ADD_SAME_C" is undefined

matlab/src/bits/impl/nnconv_cudnn.cu:207: error: argument of type "float *" is incompatible with parameter of type "cudnnTensorDescriptor_t"

matlab/src/bits/impl/nnconv_cudnn.cu:207: error: argument of type "float *" is incompatible with parameter of type "cudnnTensorDescriptor_t"

matlab/src/bits/impl/nnconv_cudnn.cu:207: error: too many arguments in function call

matlab/src/bits/impl/nnconv_cudnn.cu:319: error: argument of type "int" is incompatible with parameter of type "cudnnTensorFormat_t"

matlab/src/bits/impl/nnconv_cudnn.cu:319: error: too few arguments in function call

matlab/src/bits/impl/nnconv_cudnn.cu:328: error: too few arguments in function call

matlab/src/bits/impl/nnconv_cudnn.cu:355: error: argument of type "float *" is incompatible with parameter of type "cudnnConvolutionBwdFilterAlgo_t"

matlab/src/bits/impl/nnconv_cudnn.cu:355: error: argument of type "float *" is incompatible with parameter of type "size_t"

matlab/src/bits/impl/nnconv_cudnn.cu:355: error: too few arguments in function call

matlab/src/bits/impl/nnconv_cudnn.cu:367: error: argument of type "float *" is incompatible with parameter of type "cudnnConvolutionBwdDataAlgo_t"

matlab/src/bits/impl/nnconv_cudnn.cu:367: error: argument of type "float *" is incompatible with parameter of type "size_t"

matlab/src/bits/impl/nnconv_cudnn.cu:367: error: too few arguments in function call

```

完成matconvnet編譯工作后,配置matlab環境

1.    在matlab里運行 " run matconvnet/matlab/vl_setupnn.m"配置matconvnet環境
2.    “run setup_mdnet.m" 完成mdnet環境配置

運行:

由於對matlab路徑不熟悉,使用時將其目錄改為了絕對路徑

demo_tracking.m

case 'otb'
    net = fullfile('/pathto/MDNet/models','mdnet_vot-otb.mat');

genConfig.m

case {'otb'}
    % path to OTB dataset
    benchmarkSeqHome ='/pathto/MDNet/dataset/OTB/';

效果和一些個人想法

在不進行訓練的幀上,MDNet在本機運行速度大概是 0.5s/幀 ,其中正向傳播每張圖大概用時四分之一秒(256張sample),抽取和保存sample約四份之一秒

若該幀對長期或短期記憶進行訓練,總用時大概在1.3s/幀

個人認為雖然追蹤效果很好,但是時間上消耗還是很厲害。不知道如果使用cudnn會不會有效提升效率


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM