MATLAB Coder: How do I build the ARM Compute Library for Deep Learn... (original) (raw)
MATLAB Coder: How do I build the ARM Compute Library for Deep Learning C++ code generation and deployment?
I see a few deep learning networks supported for code generation using MATLAB Coder:
I'm looking to generate code from my deep learning network (like AlexNet, GoogLeNet, ResNet, SqueezeNet, VGG-16/19, etc) to run on ARM Cortex-A processors using MATLAB Coder and the ARM Compute Library. What are the steps to do this?
Accepted Answer
Note: The following applies to R2023a and newer releases of MATLAB Coder. For older releases, see the next answer below.
Starting with Release R2023a, we recommend users to generate generic C/C++ code that does not call into the ARM Compute Library for optimal performance. Please see the following example for more details:
More Answers (1)
Background
To build and run generated C++ code for Deep Learning on an ARM hardware target, you must have the ARM Compute Library installed on the ARM target.
The following describes instructions for building the ARM Compute library on an ARM target, such as the Raspberry Pi, Hikey960, and so on. You must use the ARM Compute Library version appropriate for your MATLAB Coder release:
- For the MATLAB Coder R2018b release, use ARM Compute version 18.03.
- For the MATLAB Coder R2019a release, you can use ARM Compute version 18.03 or 18.05.
- For other MATLAB Coder releases, use the ARM Compute version specific for the release, as described in the release documentation: https://www.mathworks.com/help/coder/ug/prerequisites-for-deep-learning-with-matlab-coder.html
If you need to set up environment variables on your ARM target to point to the ARM Compute Library, see:
ARM Compute Library Build Instructions on Linux based hardware
These instructions assume that the operating system is already present on the hardware. For example, Raspbian Stretch on the Raspberry Pi. On the target hardware, open a command terminal and perform these steps.
1. Install git. Enter:
2. As noted above, you must use the ARM Compute Library appropriate for your MATLAB Coder release. To download the latest version of the ARM Compute library from https://github.com/ARM-software/ComputeLibrary, enter:
git clone https://github.com/Arm-software/ComputeLibrary.git
To use older libraries:
b. Use git commands to download a specific version. For example, to download version 18.05, use below commands:
git clone https://github.com/Arm-software/ComputeLibrary.git
3. Install scons:
sudo apt-get install scons
For example, to build the ARM Compute Library for Raspberry Pi, enter:
scons Werror=0 -j2 debug=0 neon=1 opencl=0 os=linux arch=armv7a openmp=1 examples=0 asserts=0 build=native
To build ARM Compute Library for Hikey960 with opencl, enter:
scons Werror=0 -j2 debug=0 neon=0 opencl=1 os=linux arch=arm64-v8a openmp=1 examples=0 asserts=0 build=native
5. Rename the folder ‘build’ to ‘lib’.