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.
|OS||Windows 10 Home 1703 Build 15063.0|
|Visual Studio||2017 Enterprise with 2015.3 Toolset|
R2016b_Patch_for_VS2015.3_Toolset (Not tested)
Download the zip file for your MATLAB version. Then extract the content of the archive to your MATLAB installation folder.
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|
|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|
|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;|
|env -> INCLUDE||$VCROOT\INCLUDE;|
|env -> LIB||$VCROOT\Lib\amd64;|
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.
- 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.