Main Content

Prerequisites for Deep Learning withMATLABCoder

MathWorks下载188bet金宝搏

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

  • Deep Learning Toolbox™

  • MATLAB Coder Interface for Deep Learning Libraries

TheMATLAB Coder Interface for Deep Learning Librariesis not supported forMATLAB Online™.

Third-Party Hardware and Software

You can useMATLAB Coderto 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.

You can also useMATLAB Coderto generate generic C or C++ code for deep learning networks. Such C or C++ code does not depend on any third-party libraries. For more information, seeGenerate Generic C/C++ Code for Deep Learning Networks.

Note

The paths to the required software libraries must not contain spaces or special characters, such as parentheses. On Windows®操作系统ems, 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 CPUs ARM CPUs
Hardware Requirements

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

ARM Cortex-A processors that support theNEONextension.

Software Libraries

Intel Math Kernel Library for Deep Neural Networks (MKL-DNN), v1.4. Seehttps://01.org/onednn

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

For more information on build, see this post inMATLAB Answers™://www.tatmou.com/matlabcentral/answers/447387-matlab-coder-how-do-i-build-the-intel-mkl-dnn-library-for-deep-learning-c-code-generation-and-dep

ARM Compute Library for computer vision and machine learning, versions 19.05 and 20.02.1. Seehttps://developer.arm.com/ip-products/processors/machine-learning/compute-library

Specify the version number in acoder.ARMNEONConfigconfiguration object. The default version number is v20.02.1.

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. Seeinstructions for building the libraryon GitHub.

The folder that contains the library files such aslibarm_compute.soshould be namedlib. If the folder is namedbuild, rename the folder tolib.

For more information on build, see this post inMATLAB Answers://www.tatmou.com/matlabcentral/answers/455590-matlab-coder-how-do-i-build-the-arm-compute-library-for-deep-learning-c-code-generation-and-deplo

Operating System Support

Windows, Linux®, andmacOS.

Windows and Linux only.

C++ Compiler

MATLAB Coderlocates and uses a supported installed compiler. For the list of supported compilers, seeSupported and Compatible Compilerson the MathWorks®website.

You can usemex -setupto change the default compiler. SeeChange Default Compiler.

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

On Windows, to generate code that uses the Intel MKL-DNN library by using thecodegencommand, useMicrosoft®Visual Studio®2015 or later.

On Windows, to generate generic C or C++ code that does not use any third-party libraries, useMicrosoft Visual Studioor the MinGW®compiler. For more information, seeGenerate Generic C/C++ Code for Deep Learning Networks.

Other

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

Note: The examples require separate libraries such asopencv_core.libandopencv_video.lib. TheOpenCVlibrary that ships with Computer Vision Toolbox™ does not have the required libraries and theOpenCVinstaller does not install them. Therefore, you must download theOpenCVsource and build the libraries.

For more information, refer to the OpenCV documentation.

Environment Variables

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

Platform Variable Name Description
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

SetARM_COMPUTELIBon the ARM target hardware.

路径

Path to the Intel MKL-DNN library folder.

For example:

C:\Program Files\mkl-dnn\lib

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/

SetLD_LIBRARY_PATHon 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/

SetARM_COMPUTELIBon the ARM target hardware.

macOS INTEL_MKLDNN

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

For example:

/usr/local/mkl-dnn

UNIX®based OS on ARM targets OPENCV_DIR

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

For example:

/usr/local/opencv/build

Note

To generate code for Raspberry Pi™ using theMATLAB Support Package for Raspberry Pi Hardware, you must set the environment variables non-interactively. For instructions, see//www.tatmou.com/matlabcentral/answers/455591-matlab-coder-how-do-i-setup-the-environment-variables-on-arm-targets-to-point-to-the-arm-compute-li

Note

To build and run examples that use OpenCV, you must install the OpenCV libraries on 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 the target board, set theOPENCV_DIRand路径environment variables as described in the previous table.

Related Topics