You should now be inside the Raspberry Pi OS file system as root with the
Install required software to build MXNet.
apt upgrade -y
apt-get -y install git cmake ninja-build gfortran liblapack* libblas* libopencv* libopenblas* python3-dev python3-pip python-dev virtualenv
pip3 install Cython
root change to user
pi to build the application.
Change to the home directory for user
pi, this is the default user for Raspberry Pi OS.
Clone the MXNet application from GitHub.
git clone https://github.com/apache/incubator-mxnet.git --recursive
Create a new directory for the build.
Run the build commands,
cmake to configure the build and
ninja to do the compilation.
-j option with the number of available CPUs.
Wait for the compile to complete. The required time to finish depends on the machine speed and number of CPUs available. More CPUs will shorten the compile time.
When the compile is complete, install the application.
sudo pip3 install -e .
Test the result with Python.
Using a text editor copy and paste the code below into a text file named
Run the example code:
The version of MXNet should be printed.
The expected output format is below. Your version may be slightly different.
Building MXNet takes about 20 minutes on an AWS c6g.2xlarge EC2 instance.
A native build on a Raspberry Pi 4 can be done using the steps above. Setting the number of jobs too high will result in out of memory failures. With
-j4 and the build fails, even on a Raspberry Pi with Gb RAM. With
-j1 the build completes, but takes over 6 hours.
Continue to the next section to download the new image and install it on a Raspberry Pi for testing.