Raspberry Pi PyTorch Installation Notes

Raspberry Pi PyTorch Installation


PyTorch XOR example


This labnote was last updated on 12/25/2020

This installation is based on the build described at this website:



System Requirements

Raspberry Pi 3 or 4

Raspberry Pi OS 64 bit

Confirm your Raspberry Pi is running the 64 bit version of Raspberry Pi OS

command: unname -a

Raspberry Pi OS version check

aarch64 should be part of the version information

This install will not work with the 32 bit version of Raspberry Pi OS

Instructions to install the 64bit version of the Raspberry Pi OS can be found here: Raspberry Pi OS 64bit Installation Notes

Download PyTorch wheels

PyTorch wheel download location

Download both wheels for torch and torchvision

Copy the wheel fiels to a directory on the Raspberry Pi

(we created and used a directory called PyTorch)

PyTorch Directory


PyTorch wheels in PyTorch Directory


Install the prerequisites

sudo apt-get install python3-numpy python3-wheel python3-setuptools python3-future python3-yaml python3-six python3-requests python3-pip python3-pillow

sudo apt install libopenblas-dev libblas-dev m4 cmake cython python3-dev

sudo apt-get install libopenblas-base libopenmpi-dev


sudo apt-get example



Installed prerequisite libraries


Install the wheel files

Change to wheel directory (cd PyTorch)

Run install

Sudo pip3 install torch*.whl torchvision*.whl

wheel installation example


Wheel installation complete

Test Installation

Test the installation by creating a simple tensor in PyTorch

With in Python 3, run the following simple program:

import torch



PyTorch test tensor


Raspberry Pi PyTorch Installation Notes

Copyright 2022 - Zagros Robotics, All Rights Reserved - Please send webpage comments or corrections to webmaster@zagrosrobotics.com - Zagros Robotics,PO Box 460342, St. Louis, MO 63146, info@zagrosrobotics.com for answers to any questions.