ML Blog

雕刻时光
Sculpting in time

Do one thing and do it well.
Every story has a beginning and an end.

Run Mathematica armhf on RaspberryPi aarch64

Running Mathematica on an AARCH64 system

3-Minute Read

Why

The Mathematica + Python web framework is used to provide an external service platform, which, due to the fact that it is running on the machine, can be used as an external service. ARM Mathematica currently only supports 32-bit v6 v7, but a runtime library for armhf v6 v7 needs to be added to aarch64.

Small TIPS

To be able to run Mathematica ARM 32Bit on Ubuntu 20.04 aarch64 systems, a review of the A lot of information about it, and finally the experiment worked, and you can run 32-bit Mathematica on an aarch64 system in the following way.

The most important line is this one: dpkg –add-architecture armhf Add the armhf source, then install the corresponding armhf libc libc++ zlib.

Mathematica installers are available here.

FROM ubuntu:20.04

RUN apt-get update
RUN dpkg --add-architecture armhf
RUN apt-get update
RUN apt-get install libc6-dev:armhf libstdc++-9-dev:armhf zlib1g-dev:armhf
COPY ./ /tmp/
WORKDIR /tmp
RUN apt install ./wolframscript_1.4.0+2020081702_armhf.deb -y
RUN apt install ./wolfram-engine_12.1.1+2020081901_armhf -y
WORKDIR /

Python Web and Wolfram Backend Demo

This corresponds to the Mathematica armhf version. The installation of gcc and g++ are both armhf versions, so we install Python and Python Modules also need to be mapped to armhf.

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 ./get-pip.py

There may be some dependencies that are not installed, so you will need to apt-get download the installer and install the python modules dependencies manually.

pip3 install wolframclient

pip3 install wolframwebengine

Dependency List:

aiohttp==3.6.2
async-timeout==3.0.1
attrs==20.1.0
certifi==2020.6.20
chardet==3.0.4
idna==2.10
multidict==4.7.3
numpy==1.17.4
oauthlib==3.1.0
pytz==2020.1
pyzmq==18.1.1
requests==2.24.0
urllib3==1.25.10
wolframclient==1.1.4
wolframwebengine==1.0.2
yarl==1.5.1

错误

During the installation, since our platform is aarch64 and the compiler uses armhf, it is possible that The following error was encountered.

    File "/usr/local/lib/python3.8/dist-packages/wheel/bdist_wheel.py", line 278, in get
_tag
      assert tag in supported_tags, "would build wheel with unsupported tag {}".format(t
ag)
  AssertionError: would build wheel with unsupported tag ('cp38', 'cp38', 'linux_aarch64
')
  ----------------------------------------
  ERROR: Failed building wheel for yarl
Failed to build yarl
ERROR: Could not build wheels for yarl which use PEP 517 and cannot be installed directl
y

The solution is to download the source package and install it with python3 setup.py install.

Demo

git clone https://github.com/WolframResearch/WolframWebEngineForPython.git
python3  -m wolframwebengine --demo --kernel /opt/Wolfram/WolframEngine/12.1/Executables/WolframKernel --domain 0.0.0.0

Finally, once we run through the official demo, our mathematica web build on aarch64 is complete!

Wolfram NetModel Server

After deploying the above tests, we are ready to develop and host our own Wolfram NetModel Web Services. up.

We will run our trained deep learning model on a Raspberry pi 4 cluster and then direct the traffic to our cluster via Cloudflare Argo, exposing our model interface to the outside world.

This will allow us to go from Model Design->Model Development->Model Development to Model Development based on Wolfram Neural Network. The whole process of Type Training->Go Live.

Get argo connection certificate: cloudflared tunnel login

Testing connectivity: cloudflared –hostname model.cineneural.com –hello-world

open web: cloudflared tunnel –hostname model.cineneural.com http://192.168.1.114:18000

Instant access to services running on the intranetmodel.cineneural.com

Information about Cloudflare Argo:

Cloudflare Argo

Cloudflare Argo Tunnel with Rust+Raspberry Pi

Recent Posts

Categories

About

不断的学习思考, 保持好奇心
Keep thinking, Stay curious
始终保持对于新事物的敏感
Always be sensitive to new things