A very kind friend knew I have a faible for smallish devices running PyTorch and sent me a Jetson NX. So naturally I built PyTorch for it.
For an online course, I created an entire set of builds (PyTorch, ONNXRuntime, ARM Compute Library, TVM) and instructions to run on Raspberry Pi OS. These use PyTorch master.
At the Developers Day, PyTorch announced the availability of official ARM64 packages for the nightly (development version) builds. You can install them using the command from the Get Started page, i.e.
pip install numpy
pip install --pre torch torchvision torchaudio -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
Here are PyTorch images for the 64bit Raspberry Pi OS, compiled on a Raspberry Pi 4 sponsored by MathInf GmbH.
These are built off the release tag commits in PyTorch (but I left them to show as 1.6aXX because they are not official builds).
I hope these will be useful and plan to keep them updated (until PyTorch officially takes over).
MathInf offers (awesome, no-nonsense) PyTorch workshops, please contact me, Thomas Viehmann.
All requirements can be installed through apt followed by the install of the whl files:
sudo apt-get install python3-numpy python3-wheel
python3-setuptools python3-future python3-yaml python3-six
python3-requests python3-pip python3-pillow
sudo pip3 install torch*.whl torchvision*.whl
I use them with Raspberry Pi OS ARM64, the current version is based on Debian Buster.
During my testing, JIT tracing didn't work for 32 bit. As JITing your model is something that comes to mind with ARM, I thought it was better to work with the (working) 64 bit version.
PyTorch wheels also contain a full version of LibTorch, the C++ frontend, so you can point CMake to /usr/local/lib/python3.7/dist-packages/torch/share/cmake/Torch/ to build C++ projects (and the required libraries for running lie in torch/lib). You could also unzip the whl and throw away the Python parts.
With a 8GB Raspberry Pi 4 (and without needing swap) starting from the minimal Raspberry Pi OS (Buster), I built with
apt-get install python3-numpy ccache git ninja-build
python3-wheel python3-setuptools python3-future python3-yaml
python3-six python3-requests cmake python3-dev python3-pip
python3-pillow
git clone -b v1.6.0 --depth 1 --recursive https://github.com/pytorch/pytorch.git
BUILD_CAFFE2_OPS=0 USE_FBGEMM=OFF USE_FAKELOWP=OFF
PATH=/usr/lib/ccache:$PATH python3 setup.py bdist_wheel
These are Python packages for PyTorch and related packages running on Debian Buster ARM64. The packages have been compiled for a PyTorch on the Raspberry Pi workshop at the end of September 2019 and reflect the git repositories at the given dates. (TVM comes from the PyTorch/TVM repository. We also had the ARM compute library, but that is not in a whl.)
The workshop covered everything around PyTorch and ARM, including Extending PyTorch, PyTorch JIT, internals of PyTorch, PyTorch+TVM, and Quantization. All topics were introduced in depth and included a hands-on section to actually use the things.
They are designed to run unter Debian Buster ARM64 with all dependencies coming from Debian. We ran these on the Raspberry Pi 4 in a chroot and using the Raspberry Pi-Foundation provided 64 bit kernel.
They are provided under the licenses of the original projects with no warranty at all. Please do not report bugs in these packages to the original projects before verifying that they also occur when you built the projects according to their build instructions!
For questions and inquiries how to get your own (awesome, no-nonsense) PyTorch workshop, please contact Thomas Viehmann.
Name | Last modified | Size | ||
---|---|---|---|---|
onnx-1.5.0-cp37-cp37m-linux_aarch64.whl | 2019-09-30 13:24 | 4.0M | The Notebook got a break and the Raspberry Pi did all the work... | |
onnxruntime-0.5.0-cp37-cp37m-linux_aarch64.whl | 2019-09-30 13:24 | 1.9M | ||
topi-0.6.dev0-py3-none-any.whl | 2019-09-30 13:24 | 582K | ||
torch-1.3.0a0-cp37-cp37m-linux_aarch64.whl | 2019-09-30 13:27 | 50M | ||
torch_tvm-0.0.1-cp37-cp37m-linux_aarch64.whl | 2019-09-30 13:27 | 263K | ||
torchvision-0.5.0a0-cp37-cp37m-linux_aarch64.whl | 2019-09-30 13:28 | 20M | ||
tvm-0.6.dev0-cp37-cp37m-linux_aarch64.whl | 2019-09-30 13:29 | 5.8M | ||
xgboost-0.90-cp37-cp37m-linux_aarch64.whl | 2019-09-30 13:29 | 2.2M | ||