# Note: MatConvNet installation on Windows 10, Matlab 2019b
## Requirements
1. Matlab R2019b
2. Cuda 10.0 (https://developer.nvidia.com/cuda-10.0-download-archive)
3. Cudnn v7.6.5 for CUDA 10.0 (https://developer.nvidia.com/rdp/cudnn-download), login required.
4. MatConvNet v1.0-beta25 (http://www.vlfeat.org/matconvnet/)
5. Microsoft Visual Studio Community 2017 v15.9( https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2017-relnotes)
## Steps
1. Install Visual Studio Community 2017
You have to include the C++ compiler. After installation, launch VSC to initialize and restart the system.

2. Install cuda10.0
Just default settings is good.
3. Unpack Cudnn
just unpack the cudnn and place the root directory `cudnn-10.0-windows10-x64-v7.6.5.32\` to where you want. (in my case, I place it under `C:\Program Files\MATLAB\R2019b\`)
4. MatConvNet Settings
My working directory is `C:\..\matconvnet-1.0-beta25\matlab`.
The compiling command I used as follows:
```
vl_compilenn('enableGpu',true,'Debug',1,'cudaRoot','C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0','cudaMethod' ,'nvcc','enableCudnn', true,'cudnnRoot', 'C:\Program Files\MATLAB\R2019b\cudnn-10.0-windows10-x64-v7.6.5.32\cuda','verbose', 2)
```
where `cudaRoot` and `cudnnRoot` may changes depends on where you install them.
## Debugging
The debug path may different when you are using different environments. Here I only shows how I deal with
1. cl.exe not found
```
'cl.exe' 不是內部或外部命令、可執行的程式或批次檔。
Error using vl_compilenn>check_clpath (line 656)
Unable to find cl.exe
Error in vl_compilenn (line 426)
cl_path = fileparts(check_clpath()); % check whether cl.exe in path
```
Simply copy the corresponding cl.exe to the working directory. For example, `C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\cl.exe`
2. nvcc_compile error
```
Error using vl_compilenn>nvcc_compile (line 615)
Command "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin\nvcc" -c -o
"C:\..\matconvnet-1.0-beta25n\matlab\mex\.build\bits\data.obj"
"C:\..\matconvnet-1.0-beta25n\matlab\src\bits\data.cu" -DENABLE_GPU -DENABLE_DOUBLE -DENABLE_CUDNN -I"C:\Program
Files\MATLAB\R2019b\cudnn-10.0-windows10-x64-v7.6.5.32\cuda\include" -v -g -DDEBUG -D_FORCE_INLINES --std=c++11 -I"C:\Program
Files\MATLAB\R2019b\extern\include" -I"C:\Program Files\MATLAB\R2019b\toolbox\parallel\gpu\extern\include"
-gencode=arch=compute_75,code=\"sm_75,compute_75\" --compiler-options=/MD --compiler-bindir="C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\VC\bin" failed.
Error in vl_compilenn (line 487)
nvcc_compile(opts, srcs{i}, objfile, flags) ;
```
The actual error message is not displayed. However, it is typically a path not found error in augment `--compiler-bindir`, so that you can run matlab as administrator and type `mkdir('C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\VC\bin')`.
3. error using mex
```
Error using mex
'C:\..\matconvnet-1.0-beta25n\matlab\mex\vl_nnconv.mexw64' compiled with '-R2018a' and linked with '-R2017b'. For more
information, see MEX file compiled with one API and linked with another.
Error in vl_compilenn>mex_link (line 627)
mex(args{:}) ;
Error in vl_compilenn (line 500)
mex_link(opts, objs, flags.mex_dir, flags) ;
```
In this case, it can be resolved by replacing line 621 in vl_compilenn.m as:
`flags.base, flags.mexlink{2:end}, '-R2018a', ...`

4. finish
will display the message
```
MEX completed successfully.
Copying CuDNN dll to mex folder.
```