VL_COMPILENN - Compile the MatConvNet toolbox.
vl_compilenn() function compiles the MEX files in the
MatConvNet toolbox. See below for the requirements for compiling
CPU and GPU code, respectively.
vl_compilenn('OPTION', ARG, ...) accepts the following options:
Set to true in order to enable GPU support.
Set the verbosity level (0, 1 or 2).
Set to true to compile the binaries with debugging information.
CudaMethod[Linux & Mac OS X:
Choose the method used to compile the CUDA code. There are two methods:
mexmethod uses the MATLAB MEX command with the configuration file
<MatConvNet>/matlab/src/config/mex_CUDA_<arch>.[sh/xml]This configuration file is in XML format since MATLAB 8.3 (R2014a) and is a Shell script for earlier versions. This is, principle, the preferred method as it uses the MATLAB-sanctioned compiler options.
nvccmethod calls the NVIDIA CUDA compiler
nvccdirectly to compile CUDA source code into object files.
This method allows to use a CUDA toolkit version that is not the one that officially supported by a particular MATALB version (see below). It is also the default method for compilation under Windows and with CuDNN.
This option specifies the path to the CUDA toolkit to use for compilation.
Set this option to
Set this option to
trueto compile the support for DOUBLE data types.
The image library to use for
A cell-array of additional flags to use when compiling
A cell-array of additional flags to use when linking
trueto compile CuDNN support. See CuDNN documentation for the Hardware/CUDA version requirements.
Directory containing the unpacked binaries and header files of the CuDNN library.
Compiling the CPU code
By default, the
EnableGpu option is switched to off, such that
the GPU code support is not compiled in.
Generally, you only need a 64bit C/C++ compiler (usually Xcode, GCC or Visual Studio for Mac, Linux, and Windows respectively). The compiler can be setup in MATLAB using the
Compiling the GPU code
In order to compile the GPU code, set the
EnableGpu option to
true. For this to work you will need:
To satisfy all the requirements to compile the CPU code (see above).
A NVIDIA GPU with at least compute capability 2.0.
The MATALB Parallel Computing Toolbox. This can be purchased from Mathworks (type
verin MATLAB to see if this toolbox is already comprised in your MATLAB installation; it often is).
A copy of the CUDA Devkit, which can be downloaded for free from NVIDIA. Note that each MATLAB version requires a particular CUDA Devkit version:
MATLAB version Release CUDA Devkit 8.2 2013b 5.5 8.3 2014a 5.5 8.4 2014b 6.0 8.6 2015b 7.0 9.0 2016a 7.5
Different versions of CUDA may work using the hack described above (i.e. setting the
The following configurations have been tested successfully:
Windows 7 x64, MATLAB R2014a, Visual C++ 2010, 2013 and CUDA Toolkit 6.5. VS 2015 CPU version only (not supported by CUDA Toolkit yet).
Windows 8 x64, MATLAB R2014a, Visual C++ 2013 and CUDA Toolkit 6.5.
Mac OS X 10.9, 10.10, 10.11, MATLAB R2013a to R2016a, Xcode, CUDA Toolkit 5.5 to 7.5.
GNU/Linux, MATALB R2014a/R2015a/R2015b/R2016a, gcc/g++, CUDA Toolkit 5.5/6.5/7.5.
Compilation on Windows with MinGW compiler (the default mex compiler in
Matlab) is not supported. For Windows, please reconfigure mex to use
Visual Studio C/C++ compiler.
Furthermore your GPU card must have ComputeCapability >= 2.0 (see
gpuDevice()) in order to be able to run the GPU code.
To change the compute capabilities, for
the particular config file. For the 'nvcc' method, compute
capability is guessed based on the GPUDEVICE output. You can
override it by setting the 'CudaArch' parameter (e.g. in case of
multiple GPUs with various architectures).