zoukankan      html  css  js  c++  java
  • 使用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会不会有效提升效率

  • 相关阅读:
    css--display属性中inline-block与inline的区别
    css基础--常用css属性01
    css基础--简单介绍css
    html常用标签的使用方法
    html概括
    python基础之socket与socketserver
    linux基础命令之sed
    asp.net文件流下载的代码摘要
    window下golang生成静态库给C语言调用
    golang生成c-shared so供c语言或者golang调用到例子
  • 原文地址:https://www.cnblogs.com/version0/p/7729076.html
Copyright © 2011-2022 走看看