今天尝试在自己电脑上配置matconvnet,出现了很多莫名其妙的问题,总结记录如下:

官网上的安装教程如下:http://www.vlfeat.org/matconvnet/install

 

1、MATLAB2013不支持vs2013,所以在MATLAB command window输入mex -setup时会提示找不到编译器vs2013

参考网上的解决办法:http://blog.csdn.net/gotomic/article/details/29594247

                            https://jingyan.baidu.com/article/1612d50044d0f2e20f1eee10.html

 

2、Matlab与其他软件做接口,通常需要VC编译器。

第一步:在Matlab的命令窗口输入 mex -setup可以选择VC编译器。
但有时会出现找不到VC编译器的情况。出现这种情况,通常有两种原因,一种是VC编译器比Matlab的版本新,Matlab无法识别,当然也无法使用。
还有一种情况是,Matlab未找到VC的安装位置,出现这种情况的原因可能是Matlab和VC的安装顺序不当,或者是VC未安装到默认地址,即C盘Program files文件夹下。
这种情况在mex -setup后,如果选择y,提示

第二步:找不到vs2013,所以我们选择n,手动输入vs2013的路径

>> mex -setup
 
Welcome to mex -setup.  This utility will help you set up  
a default compiler.  For a list of supported compilers, see  
http://www.mathworks.com/support/compilers/R2013a/win32.html 
 
Please choose your compiler for building MEX-files: 
 
Would you like mex to locate installed compilers [y]/n? n
 
Select a compiler: 
[1] Intel C++ 13.0 (with Microsoft Software Development Kit (SDK) linker) 
[2] Intel C++ 13.0 (with Microsoft Visual C++ 2010 linker) 
[3] Intel C++ 13.0 (with Microsoft Visual C++ 2012 linker) 
[4] Intel C++ 12.0 (with Microsoft Software Development Kit (SDK) linker) 
[5] Intel C++ 12.0 (with Microsoft Visual C++ 2008 SP1 linker) 
[6] Intel C++ 12.0 (with Microsoft Visual C++ 2010 linker) 
[7] Intel C++ 11.1 (with Microsoft Visual C++ 2008 SP1 linker) 
[8] Intel Visual Fortran 13 (with Microsoft Software Development Kit (SDK) linker) 
[9] Intel Visual Fortran 13.0 (with Microsoft Visual C++ 2010 linker) 
[10] Intel Visual Fortran 13.0 (with Microsoft Visual C++ 2012 linker) 
[11] Intel Visual Fortran 12 (with Microsoft Software Development Kit (SDK) linker) 
[12] Intel Visual Fortran 12.0 (with Microsoft Visual C++ 2008 SP1 linker) 
[13] Intel Visual Fortran 12.0 (with Microsoft Visual C++ 2008 Shell linker) 
[14] Intel Visual Fortran 12.0 (with Microsoft Visual C++ 2010 linker) 
[15] Intel Visual Fortran 11.1 (with Microsoft Visual C++ 2008 SP1 linker) 
[16] Intel Visual Fortran 11.1 (with Microsoft Visual C++ 2008 Shell linker) 
[17] Lcc-win32 C 2.4.1 
[18] Microsoft Software Development Kit (SDK) 7.1 
[19] Microsoft Visual C++ 2005 SP1 
[20] Microsoft Visual C++ 2008 SP1 
[21] Microsoft Visual C++ 2010 
[22] Microsoft Visual C++ 2012 
[23] Open WATCOM C++ 
 
[0] None 

 

第三步:选21,选n,输入自己电脑上vs的安装路径

第四步:再选y,mex就完成了(到这一步,我的32位的电脑还是不成功,有毒。。。。。)

 

3、配置matconvnet只需运行几步

(1)run vl_compilenn;

(2)run vl_setupnn

 

 4、注意一个问题,每次新建一个代码工程,都要把vlfeat和matconvnet的库放到代码的目录下,写一个setup.m文件,内容如下:

 1   %2017 05 05  CLQ修改(不然会一直报错,必须重新mex一遍才能跑)
 2 run vlfeat-0.9.20/toolbox/vl_setup
 3 
 4 if exist('vl_nnconv') ~= 3 
 5   run matconvnet-1.0-beta23/matlab/vl_setupnn
 6   if exist('vl_nnconv') ~= 3
 7     warning('MatConvNet not compiled, attempting to fix...') ;
 8     copyfile(...
 9       'matconvnet-1.0-beta23/matlab/src/vl_nnconv.cu', ...
10       'matconvnet-1.0-beta23/matlab/src/vl_nnconv.cpp') ;
11     mex('matconvnet-1.0-beta23/matlab/src/vl_nnconv.cpp', ...
12       'matconvnet-1.0-beta23/matlab//src/bits/im2col.cpp', ...
13       'matconvnet-1.0-beta23/matlab//src/bits/subsample.cpp', ...
14       '-Imatconvnet/matlab/src',...
15       '-lmwblas') ;
16   end
17 end

 

 要把两个库文件放在exercise.m的目录下!!!!!
 
 

 

posted on 2017-05-05 14:56  紫月小猫咪  阅读(3954)  评论(0编辑  收藏  举报