• Welcome to Rotar E@rth!
  • Feel free to look around and comment~
  • Tin - for a better fantasy life!
  • TinTimer - for an even better fantasy life!

MatConvNet with Visual Studio 2015.3 Toolset and MATLAB R2017a

Programming Rotar 8年前 (2017-06-26) 11414次浏览 0个评论

Introduction

After a recent re-install of Windows on my laptop, I decided to install the latest version of the software packages that I frequently use. This include MATLAB R2017a ,Visual Studio 2017 Enterprise and MatConvNet.

However, it turns out that MATLAB R2017a does not support using VS2017 out of the box (patch required). What’s worse is that CUDA Toolkit 8.0 also doesn’t support VS2017 yet.

In order to use MatConvNet for my research, I had to install VS2015.3 Toolset (optional component of VS2017) and configure MATLAB R2017a to use it.

 

System Environment

ComponentVersion
OSWindows 10 Home 1703 Build 15063.0
MATLABR2017a
CUDA Toolkit8.0.61
CuDNN5.1
Visual Studio2017 Enterprise with 2015.3 Toolset

Required Files

R2016b_Patch_for_VS2015.3_Toolset (Not tested)

R2017a_Patch_for_VS2015.3_Toolset (Tested)

Download the zip file for your MATLAB version. Then extract the content of the archive to your MATLAB installation folder.

 

Modifications

The files above are modified from msvc2015.xml and msvcpp2015.xml within ‘MATLAB\R201XX\bin\win64\mexopts’ folder with reference to the patch for VS2017.

FieldOriginal ValueNew Value
NameMicrosoft Visual C++ 2015 ProfessionalMicrosoft Visual C++ 2015.3 Toolset
ShortNameMSVC140MSVC140T
VCROOT -> pathVS7VC7
VCROOT -> fileExists -> name$$\VC\bin\amd64\cl.exe$$\bin\amd64\cl.exe
SDKROOT -> pathv8.1v10.0
VSINSTALLDIR -> pathVS7VC7
PROF_ENV...(Removed)
VCVARSALLDIR -> pathVS7VC7
VCVARSALLDIR -> fileExists -> name$$\VC\vcvarsall.bat$$\vcvarsall.bat
SDKVERSIONN/A(Section copied from VS2017 patch)
env -> PATH$VCROOT\Bin\amd64;
$VCROOT\Bin\VCPackages;
$VCROOT\..\Common7\IDE;
$VCROOT\..\Common7\Tools;
$SDKROOT\Bin\x64;
$SDKROOT\Bin\x86;
$VCROOT\Bin\amd64;
$VCROOT\..\Common7\Tools;
$SDKROOT\Bin\x64;
$SDKROOT\Bin\x86;
$SDKROOT\Bin\$SDKVERSION\x64;
$SDKROOT\Bin\$SDKVERSION\x86;
env -> INCLUDE$VCROOT\INCLUDE;
$VCROOT\ATLMFC\INCLUDE;
$KITSROOT\include\10.0.10150.0\ucrt;
$SDKROOT\include\shared;
$SDKROOT\include\um;
$SDKROOT\include\winrt;
$MATLABROOT\extern\include
$VCROOT\INCLUDE;
$VCROOT\ATLMFC\INCLUDE;
$KITSROOT\include\$SDKVERSION\ucrt;
$KITSROOT\include\$SDKVERSION\shared;
$KITSROOT\include\$SDKVERSION\um;
$KITSROOT\include\$SDKVERSION\winrt;
$MATLABROOT\extern\include
env -> LIB$VCROOT\Lib\amd64;
$VCROOT\ATLMFC\Lib\amd64;
$KITSROOT\Lib\10.0.10150.0\ucrt\x64;
$SDKROOT\lib\winv6.3\um\x64;
$MATLABROOT\lib\$ARCH
$VCROOT\Lib\amd64;
$VCROOT\ATLMFC\Lib\amd64;
$KITSROOT\Lib\$SDKVERSION\ucrt\x64;
$KITSROOT\lib\$SDKVERSION\um\x64;
$MATLABROOT\lib\$ARCH

 

Compilation

First, configure MATLAB to use the VS2015.3 Toolset by using command:
mex -setup  and mex -setup C++
and clicking on the ‘Microsoft Visual C++ 2015.3 Toolset‘ option.

Then change the current directory to your MatConvNet folder (matconvnet\matlab) and use vl_compilenn  to compile. In my case, the command is as follows:

vl_compilenn('enableGpu', true, ...
               'cudaRoot', 'C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0', ...
               'cudaMethod', 'nvcc', ...
               'enableCudnn', true, ...
               'cudnnRoot', 'local/cudnn-8.0') ;

Details about parameters for vl_compilenn  can be found here. After the compilation finished, copy cudnn64_5.dll to ‘matconvnet\matlab\mex’ and you’re good to go.

Side Notes

  1. It is extremely useful to call mex  in verbose mode so that you know how the variables are set:
    mex -v -setup:’C:\Program Files\MATLAB\R2017a\bin\win64\mexopts\YOURCONFIGURE.xml’
  2. In the locationFinder part,  $$ means the current variable found by proceeding commands.
    For example, the $$ in fileExists  in <VCROOT>  represents %VCROOT  itself as found by the hkXXExists commands.

本网站采用BY-NC-SA协议进行授权 , 转载请注明原文链接:MatConvNet with Visual Studio 2015.3 Toolset and MATLAB R2017a
喜欢 (1)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址