Installing and compiling the library
In order to install the library, follows these steps:
- Download and unpack the library source code into a directory of your choice. Call the path to this directory
<MatConvNet>
. - Compile the library.
At this point the library is ready to use. You can test it by using the command (using MATLAB R2014a or later):
Compiling
MatConvNet compiles under Linux, Mac, and Windows. This page discusses compiling MatConvNet using the MATLAB function
vl_compilenn
. While this is the easiest method,
the command line or an IDE can be used as well.unbuntu使用gcc編譯器就可以了
Compiling for CPU
If this is the first time you compile MatConvNet, consider trying first the CPU version. In order to do this, use the
vl_compilenn
command supplied with the library:
- Make sure that MATLAB is configured to use your compiler.
- Open MATLAB and issue the commands:
> cd <MatConvNet> > addpath matlab > vl_compilenn
At this point MatConvNet should start compiling. If all goes well, you are ready to use the library. If not, you can try debugging the problem by running the compilation script again in verbose mode:
> vl_compilenn('verbose', 1)
Increase the verbosity level to 2 to get even more information.
Remark: The 'vl_imreadjpeg' tool uses an external image library to load images. In Mac OS X and Windows, the default is to use the system libraries (Quartz and GDI+ respectively), so this dependency is immaterial. In Linux, this tool requires the LibJPEG library and the corresponding development files to be installed in the system. If needed, the
ImageLibraryCompileFlags
andImageLibraryLinkFlags
options can be used to adjust the compiler and linker flags to match a specific library installation. It is also possible to use theEnableImreadJpeg
option ofvl_compilenn
to turn off this feature.
大部分情況下是需要使用GPU編譯的,比如CVPR2016中MDNet(Multi-Domain Convolutional Neural Networks )的安裝使用
Compiling the GPU support
To use the GPU-accelerated version of the library, you will need a NVIDA GPU card with compute capability 2.0 or greater and a copy of the NVIDIA CUDA toolkit. Ideally, the version of the CUDA toolkit should match your MATLAB version:
MATLAB | CUDA toolkit |
---|---|
R2013b | 5.5 |
R2014a | 5.5 |
R2014b | 6.0 |
R2015a | 6.5 |
R2015b | 7.0 |
You can also use the gpuDevice
MATLAB command to find out MATLAB's version of the CUDA toolkit. It is also possible (and often necessary) to use a more recent version of CUDA than the one officially supported by MATLAB; this
is explained later.
Assuming that there is only a single copy of the CUDA toolkit installed in your system and that it matches MATLAB's version, compile the library with:
> vl_compilenn('enableGpu', true)
If you have multiple versions of the CUDA toolkit, or if the script cannot find the toolkit for any reason, specify the path to the CUDA toolkit explicitly. For example, on a Mac this may look like:
有時編譯會出現找不到CUDA的情況,這時候也可以打開vl_compilenn.m文件去修改CUDA的路徑到目前CUDA在系統中的安裝路徑
> vl_compilenn('enableGpu', true, 'cudaRoot', '/Developer/NVIDIA/CUDA-7.0')
Once more, you can use the verbose
option to obtain more information if needed.
last
Start MATLAB and type:
> run <MatConvNet>/matlab/vl_setupnn
in order to add MatConvNet to MATLAB's search path.