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
Component | Version |
---|---|
OS | Windows 10 Home 1703 Build 15063.0 |
MATLAB | R2017a |
CUDA Toolkit | 8.0.61 |
CuDNN | 5.1 |
Visual Studio | 2017 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.
Field | Original Value | New Value |
---|---|---|
Name | Microsoft Visual C++ 2015 Professional | Microsoft Visual C++ 2015.3 Toolset |
ShortName | MSVC140 | MSVC140T |
VCROOT -> path | VS7 | VC7 |
VCROOT -> fileExists -> name | $$\VC\bin\amd64\cl.exe | $$\bin\amd64\cl.exe |
SDKROOT -> path | v8.1 | v10.0 |
VSINSTALLDIR -> path | VS7 | VC7 |
PROF_ENV | ... | (Removed) |
VCVARSALLDIR -> path | VS7 | VC7 |
VCVARSALLDIR -> fileExists -> name | $$\VC\vcvarsall.bat | $$\vcvarsall.bat |
SDKVERSION | N/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
- 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’ - 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.