Clear Filters
Clear Filters

MATLAB Coder: How do I build the ARM Compute Library for Deep Learning C++ code generation and deployment?

40 views (last 30 days)
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

Bill Chou
Bill Chou on 9 May 2024
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 (2)

Bill Chou
Bill Chou on 10 Apr 2019
Edited: Bill Chou on 4 Apr 2023
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:
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:
sudo apt-get install git
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, enter:
git clone
To use older libraries:
a. Download source code zip or tar file from and unzip downloaded source code. (OR)
b. Use git commands to download a specific version. For example, to download version 18.05, use below commands:
git clone
cd ComputeLibrary
git tag -l
git checkout v18.05
3. Install scons:
sudo apt-get install scons
cd ComputeLibrary
4. Build the library by running the scons command with the relevant build options. For information on library build options, see The ARM Compute libraries are generated under the folder 'build'.
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’.
  1 Comment
Riccardo Vocale
Riccardo Vocale on 27 Oct 2021
Edited: Riccardo Vocale on 27 Oct 2021
when i try to bild my model on simulink i get this error
Unable to find Arm Compute library for selected version. To install ARM compute library run the Hardware Setup process.
how can i link the arm folder to matlab? i am using android device

Sign in to comment.

ASANTE on 20 Jun 2024 at 19:01
% Time-drawdown data
time = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 75, 90, 105, 120, 135, 150, 165, 180]; % time in minutes
drawdown = [0.00, 3.36, 3.77, 5.13, 6.14, 5.85, 7.18, 7.58, 7.85, 8.06, 8.14, 8.26, 8.67, 8.84, 9.04, 9.23, 9.35, 9.44, 9.58, 9.64, 9.72, 9.96, 10.61, 10.77, 11.39, 11.73, 12.14, 12.61, 12.76]; % drawdown in meters
% Remove the first data point (time = 0) for log calculation
time = time(2:end);
drawdown = drawdown(2:end);
% Cooper-Jacob method to estimate transmissivity (T) and storativity (S)
% Assume a constant pumping rate Q
Q = 0.0011; % pumping rate in m^3/s
% Logarithm of time
log_time = log10(time);
% Linear fit to log(time) vs drawdown
p = polyfit(log_time, drawdown, 1);
slope = p(1);
intercept = p(2);
% Transmissivity (T) and storativity (S) calculation
T = 2.3 * Q / (4 * pi * slope); % transmissivity in m^2/s
S = 2.25 * T * 10^intercept / (Q * 1000); % storativity (dimensionless)
% Display the results
disp(['Transmissivity (T): ', num2str(T), ' m^2/s']);
disp(['Storativity (S): ', num2str(S)]);
% Create input-output pairs for ANN training
input_data = log_time'; % log(time)
output_data = drawdown'; % drawdown
% Define and train the ANN
net = feedforwardnet(10); % 10 hidden neurons (you can adjust this)
net = train(net, input_data, output_data);
% Predict drawdown using the trained ANN
predicted_drawdown = net(input_data);
% Plot the results
plot(log_time, drawdown, 'bo', 'DisplayName', 'Observed Drawdown');
hold on;
plot(log_time, predicted_drawdown, 'r-', 'DisplayName', 'ANN Predicted Drawdown');
ylabel('Drawdown (m)');
title('Drawdown vs Log(Time)');
grid on;
% Estimate hydraulic conductivity (K) given T and aquifer thickness (b)
b = 10; % example aquifer thickness in meters
K = T / b; % hydraulic conductivity in m/s
% Display the hydraulic conductivitydisp(['Hydraulic Conductivity (K): ', num2str(K), '

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!