VL_COMPILENN
- Compile the MatConvNet toolbox.
The 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:
-
EnableGpu
[false
]Set to true in order to enable GPU support.
-
Verbose
[0]Set the verbosity level (0, 1 or 2).
-
Continue
[false]Avoid recreating a file if it was already compiled. This uses a crude form of dependency checking, so it may occasionally be necessary to rebuild MatConvNet without this option.
-
Debug
[false
]Set to true to compile the binaries with debugging information.
-
CudaMethod
[Linux & Mac OS X:mex
; Windows:nvcc
]Choose the method used to compile the CUDA code. There are two methods:
-
The
mex
method uses the MATLAB MEXCUDA command. This is, in principle, the preferred method as it uses the MATLAB-sanctioned compiler options. -
The
nvcc
method calls the NVIDIA CUDA compilernvcc
directly 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.
-
-
CudaRoot
[guessed automatically]This option specifies the path to the CUDA toolkit to use for compilation.
-
EnableImreadJpeg
[true
]Set this option to
true
to compilevl_imreadjpeg
. -
EnableDouble
[true
]Set this option to
true
to compile the support for DOUBLE data types. -
ImageLibrary
[libjpeg
(Linux),gdiplus
(Windows),quartz
(Mac)]The image library to use for
vl_impreadjpeg
. -
ImageLibraryCompileFlags
[platform dependent]A cell-array of additional flags to use when compiling
vl_imreadjpeg
. -
ImageLibraryLinkFlags
[platform dependent]A cell-array of additional flags to use when linking
vl_imreadjpeg
. -
EnableCudnn
[false
]Set to
true
to compile CuDNN support. See CuDNN documentation for the Hardware/CUDA version requirements. -
CudnnRoot
['local/'
]Directory containing the unpacked binaries and header files of the CuDNN library.
-
MexConfig
[none]Use this option to specify a custom
.xml
configuration file fot themex
compiler. -
MexCudaConfig
[none]Use this option to specify a custom
.xml
configuration file fot themexcuda
compiler. -
preCompileFn
[none]Applies a custom modifier function just before compilation to modify various compilation options. The function's signature is: [opts, mex_src, lib_src, flags] = f(opts, mex_src, lib_src, flags) ; where the arguments are a struct with the present options, a list of MEX files, a list of LIB files, and compilation flags, respectively.
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
mex -setup
command.
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
ver
in 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 9.2 2017a 8.0 9.1 2016b 7.5 9.0 2016a 7.5 8.6 2015b 7.0 Different versions of CUDA may work using the hack described above (i.e. setting the
CudaMethod
tonvcc
).
The following configurations or anything more recent (subject to versionconstraints between MATLAB, CUDA, and the compiler) should work:
-
Windows 10 x64, MATLAB R2015b, Visual C++ 2015, CUDA Toolkit 8.0. Visual C++ 2013 and lower is not supported due to lack C++11 support.
-
macOS X 10.12, MATLAB R2016a, Xcode 7.3.1, CUDA Toolkit 7.5-8.0.
-
GNU/Linux, MATALB R2015b, gcc/g++ 4.8.5+, CUDA Toolkit 7.5-8.0.
Many older versions of these components are also likely to work.
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
output of gpuDevice()
) in order to be able to run the GPU code.
To change the compute capabilities, for mex
CudaMethod
edit
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).
See also: Compliling MatConvNet,
Compiling MEX files containing CUDA
code,
vl_setup()
, vl_imreadjpeg()
.