This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Prerequisites for Deep Learning with MATLAB Coder

MathWorks Products

To use MATLAB® Coder™ to generate code for deep learning networks, you must also install:

  • Deep Learning Toolbox™

  • MATLAB Coder Interface for Deep Learning Libraries

Third-Party Hardware and Software

You can use MATLAB Coder to generate C++ code for deep learning networks that you deploy to Intel® or ARM® processors. The generated code takes advantage of deep learning libraries optimized for the target CPU. The hardware and software requirements depend on the target platform.

Note

The paths to the required software libraries must not contain spaces or special characters, such as parentheses. On Windows® operating systems, special characters and spaces are allowed only if 8.3 file names are enabled. For more information on 8.3 file names, refer to the Windows documentation.

 Intel CPUsARM CPUs
Hardware Requirements

Intel processor with support for Intel Advanced Vector Extensions 2 (Intel AVX2) instructions.

ARM Cortex-A processors that support the NEON extension.

Software Libraries

Intel Math Kernel Library for Deep Neural Networks, v0.14 (Intel MKL-DNN).

Do not use a prebuilt library because some required files are missing. Instead, build the library from the source code. See instructions for building the library on GitHub®.

After you build the MKL-DNN library, copy required files from the folder where you downloaded and built the source to an MKL-DNN installation folder. Set the environment variable INTEL_MKLDNN to this MKL-DNN installation folder. See Environment Variables.

  1. Copy library files to mkl_dnn_installation_folder/lib.

    If you build on Windows, copy these files:

    • libiomp5md.lib

    • libiomp5md.dll

    • mklml.lib

    • mklml.dll

    • mkldnn.lib

    • mkldnn.dll

    If you build on Linux, copy these files:

    • libiomp5.so

    • libmkldnn.so

    • libmkldnn.so.0

    • libmkldnn.so.0.14.0

    • libmklml_intel.so

  2. Copy these header files to mkl_dnn_installation_folder/include:

    • mkldnn.h

    • ​mkldnn.hpp

    • mkldnn_debug.h

    • mkldnn_types.h

ARM Compute Library for computer vision and machine learning, v18.03 or v18.05. Specify the version number in a coder.ARMNEONConfig configuration object or in the targetparams name-value pair argument of the cnncodegen command. The default version number is v18.05.

If you specify a version of the ARM Compute Library that is later than v18.05, the code generator produces code for v18.05. On the ARM target, the generated code can build with the later version of the library.

Do not use a prebuilt library because it might be incompatible with the compiler on the ARM hardware. Instead, build the library from the source code. Build the library on either your host machine or directly on the target hardware. See instructions for building the library on GitHub.

Operating System Support

Windows and Linux® only.

Windows and Linux only.

C++ Compiler

MATLAB Coder locates and uses a supported installed compiler. For the list of supported compilers, see Supported and Compatible Compilers on the MathWorks® website.

You can use mex -setup to change the default compiler. See Change Default Compiler (MATLAB).

The C++ compiler must support C++11.

On Windows, code generation for deep learning networks by using the codegen command requires Microsoft® Visual Studio® 2015 or later.

Other

Open Source Computer Vision Library (OpenCV), v3.1.0 is required for some deep learning examples.

Note: The examples require separate libraries such as opencv_core.lib and opencv_video.lib. The OpenCV library that ships with Computer Vision Toolbox™ does not have the required libraries and the OpenCV installer does not install them. Therefore, you must download the OpenCV source and build the libraries.

For more information, refer to the OpenCV documentation.

Environment Variables

MATLAB Coder uses environment variables to locate the libraries required to generate code for deep learning networks.

PlatformVariable NameDescription
Windows INTEL_MKLDNN

Path to the root folder of the Intel MKL-DNN library installation.

For example:

C:\Program Files\mkl-dnn

ARM_COMPUTELIB

Path to the root folder of the ARM Compute Library installation on the ARM target hardware.

For example:

/usr/local/arm_compute

Set ARM_COMPUTELIB on the ARM target hardware. If you generate code by using cnncodegen, also set ARM_COMPUTELIB on the host computer that you use for code generation.

OPENCV_DIR

Path to the build folder of OpenCV. Install OpenCV for deep learning examples that use OpenCV.

For example:

C:\Program Files\opencv\build

PATH

Path to the Intel MKL-DNN library folder.

For example:

C:\Program Files\mkl-dnn\lib

Path to the dynamic-link libraries (DLL) of OpenCV. Install OpenCV for deep learning examples that use OpenCV.

For example:

C:\Program Files\opencv\build\x64\vc15\bin

Linux LD_LIBRARY_PATH

Path to the Intel MKL-DNN library folder.

For example:

/usr/local/mkl-dnn/lib/

Path to the ARM Compute Library folder on the target hardware.

For example:

/usr/local/arm_compute/lib/

Set LD_LIBRARY_PATH on the ARM target hardware.

INTEL_MKLDNN

Path to the root folder of the Intel MKL-DNN library installation.

For example:

/usr/local/mkl-dnn/

ARM_COMPUTELIB

Path to the root folder of the ARM Compute Library installation on the ARM target hardware.

For example:

/usr/local/arm_compute/

Set ARM_COMPUTELIB on the ARM target hardware. If you generate code by using cnncodegen, also set ARM_COMPUTELIB on the host computer that you use for code generation.

Note

To build and run examples that use OpenCV, you must install the OpenCV libraries on the host computer or the target board. For OpenCV installations on Linux, make sure that the path to the library files and the path to the header files are on the system path. By default, the library and header files are installed in a standard location such as /usr/local/lib/ and /usr/local/include/opencv, respectively.

For OpenCV installations on Windows, set the OPENCV_DIR and PATH environment variables as described in the previous table.

Related Topics