MATLAB Answers

MATLAB Coder: How do I setup the environment variables on ARM targets to point to the ARM Compute Library?

54 views (last 30 days)
I see a few deep learning networks supported for code generation using MATLAB Coder:
And I've seen the question here about building the ARM Compute Library:
The next question I have is, how do I set the environment variables on ARM targets to point to the ARM Compute Library?

  0 Comments

Sign in to comment.

Accepted Answer

Bill Chou
Bill Chou on 10 Apr 2019
To avoid build failures on ARM hardware targets, such as the Raspberry Pi and Hikey960, you must set the necessary environment variables non-interactively.
For example, with the ComputeLibrary folder installed under ~, the user home directory, and the ARM Compute libraries stored at ~/ComputeLibrary/lib, you can add this code block to the file ~/.bashrc:
#Set below block, if you use your hardware non-interactively (through ssh from remote host or tty/new terminal onto local machine)
case $- in
*i*) ;;
*)
export ARM_COMPUTELIB=~/ComputeLibrary
export PATH=${PATH}:~/ComputeLibrary
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:~/ComputeLibrary/lib
return;;
esac

  3 Comments

Davide Buellis
Davide Buellis on 24 Sep 2019
Hi Bill!
Could you please help me on an issue I am encountering? I am performing the example "Code Generation for Deep Learning on Raspberry Pi" and I followed your tutorials on how to install the Arm Compute Library and the environmental variables.
Compiling, though, an error comes out:
Error executing command "touch -c /home/pi/remoteBuildDir/MATLAB_ws/R2019b/C/Users/Buellis/Documents/MATLAB/Examples/R2019a/deeplearning_shared/CodeGenerationForDeepLearningOnRaspberryPiExample/codegen/exe/squeezenet_raspi_predict/*.*;make -f squeezenet_raspi_predict_rtw.mk all MATLAB_WORKSPACE="/home/pi/remoteBuildDir/MATLAB_ws/R2019b" -C /home/pi/remoteBuildDir/MATLAB_ws/R2019b/C/Users/Buellis/Documents/MATLAB/Examples/R2019a/deeplearning_shared/CodeGenerationForDeepLearningOnRaspberryPiExample/codegen/exe/squeezenet_raspi_predict". Details:
STDERR: In file included from /home/pi/remoteBuildDir/MATLAB_ws/R2019b/C/Users/Buellis/Documents/MATLAB/Examples/R2019a/deeplearning_shared/CodeGenerationForDeepLearningOnRaspberryPiExample/codegen/exe/squeezenet_raspi_predict/MWDepthConcatenationLayerImpl.hpp:6,
from /home/pi/remoteBuildDir/MATLAB_ws/R2019b/C/Users/Buellis/Documents/MATLAB/Examples/R2019a/deeplearning_shared/CodeGenerationForDeepLearningOnRaspberryPiExample/codegen/exe/squeezenet_raspi_predict/MWDepthConcatenationLayer.cpp:4:
/home/pi/remoteBuildDir/MATLAB_ws/R2019b/C/Users/Buellis/Documents/MATLAB/Examples/R2019a/deeplearning_shared/CodeGenerationForDeepLearningOnRaspberryPiExample/codegen/exe/squeezenet_raspi_predict/MWCNNLayerImpl.hpp:11:10: fatal error: arm_compute/runtime/NEON/NEFunctions.h: No such file or directory
#include "arm_compute/runtime/NEON/NEFunctions.h"
Seems it doesn't find the file "arm_compute/runtime/NEON/NEFunctions.h", but if I go in that directory in my RPi: /home/pi/ComputeLibrary/arm_compute/runtime/NEON, the file is present!
Do you have any idea what's causing it?
Praneet Kala
Praneet Kala on 1 Nov 2019
Having the same issue. I have the entire arm_compute folder on the same path as the example which i am trying to deploy and i still get this error. It was happening with the MemoryRegion.h file and then i added the entire folder (arm_compute/runtime) to the path in MATLAB and i get this error.
Any help would be appreciated

Sign in to comment.

More Answers (2)

Torbjörn Olsson
Torbjörn Olsson on 24 Sep 2019
Hi Davide,
while you are awaiting an answer from a cunning person, I thought I draw your attention to a minor issue that perhaps could be at least part of the compiling error. The paths seems to differ by one character between the one in the error message and the one you mention in the latter part of your query, i.e. "arm_compute/runtime/" vs. "arm_compute_runtime/".

  1 Comment

Davide Buellis
Davide Buellis on 25 Sep 2019
Hi Torbjorn!
Thanks for your help! Sorry I made a typo, it is not "arm_compute_runtime/". I corrected the question.

Sign in to comment.


Hariprasad Ravishankar
Hariprasad Ravishankar on 19 Nov 2019
Hi all,
The build error "fatal error: arm_compute/runtime/NEON/NEFunctions.h: No such file or directory" suggests that the ARM_COMPUTELIB environment variable may be incorrectly set.
This may perhaps be if you have setup the envrionment variables at the end of the ~/.bashrc script instead of the beginning.
In order to execute commands non-interactively, such as the codegen command from MATLAB on a host to compile on the Raspberry Pi, the environment variables need to be setup inside the
case $- in
*i*) ;;
*)
...
return;;
esac
block in the ~/.bashrc script. This section can be found in the first few lines of the ~/.bashrc script for non-interactive,non-login shells.
Here is how it is setup for me for reference
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively
case $- in
*i*) ;;
*) export ARM_COMPUTELIB=~/ComputeLibrary
export PATH=${PATH}:~/ComputeLibrary
export LD_LIBRARY_PATH=~/opencv-3.2.0/build/lib:~/ComputeLibrary/lib:$LD_LIBRARY_PATH
return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
Alternatively, you can setup environment variables in the first few lines of the ~/.bashrc before the return;; statement
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
export ARM_COMPUTELIB=~/ComputeLibrary
export PATH=${PATH}:~/ComputeLibrary
export LD_LIBRARY_PATH=~/opencv-3.2.0/build/lib:~/ComputeLibrary/lib:$LD_LIBRARY_PATH
# If not running interactively
case $- in
*i*) ;;
*)
return;;
esac

  0 Comments

Sign in to comment.