How to use Raspberry Pi for machine learning
Training vs inference: what a Pi is good at
Machine learning has two stages. Training is where a model learns from thousands or millions of examples, adjusting its weights over and over. It takes a lot of computing power and is usually done on a computer with a powerful graphics card or in the cloud. Inference is using the finished model to make predictions on new data: is this a cat, how many people are in the room, what did that person say?
A Raspberry Pi is excellent for inference and poor for training anything large. That is fine, because most projects don't need to train from scratch: you can download a ready trained model, or fine tune one on a bigger machine and copy it to the Pi. Running AI on a small device like this is called edge AI. It works without an internet connection, keeps camera footage private, and responds without waiting for a server.
To see what training actually does, build a small network and watch it learn in our Neural Network Trainer. Then test yourself: this question gives you tasks and asks whether each is training or inference.
Sort statements into training and inference.
Press Mark to have your answer marked in the AI Models course.
Three ways to run machine learning on a Raspberry Pi
| Option | What does the work | Works with | Best for |
|---|---|---|---|
| The Pi's own CPU | The Arm processor, using a runtime such as LiteRT or PyTorch | Any recent Pi; a Pi 5 is fastest | Small models, sensor data, learning how it works |
| AI Camera | A Sony IMX500 sensor with its own AI processor | All Raspberry Pi models | Vision projects on smaller Pis |
| AI HAT+ | A Hailo-8L (13 TOPS) or Hailo-8 (26 TOPS) accelerator | Raspberry Pi 5 only | Fast, real-time object detection and pose tracking |
| AI HAT+ 2 | A Hailo-10H accelerator (40 TOPS) with 8 GB of its own memory | Raspberry Pi 5 only | Small language models and vision language models |
Prices on raspberrypi.com on 7 November 2026: the AI Camera was $70, the AI HAT+ was from $70, and the AI HAT+ 2 was $200. The older AI Kit is no longer in production; the AI HAT+ replaces it.
What you need
- A Raspberry Pi 5 if you want to use an AI HAT+. More memory helps with bigger models. Older Pis still work with the CPU route or the AI Camera.
- 64-bit Raspberry Pi OS. The Raspberry Pi AI documentation lists the current 64-bit release for the AI HAT+ boards.
- A camera for vision projects, such as the Camera Module 3 or the AI Camera.
- Cooling. AI work keeps the processor busy, so a case fan or the official active cooler stops it slowing down when hot.
- The official power supply, since add-on boards draw extra current.
New to the Pi itself? The Raspberry Pi course covers setting it up, the terminal and the GPIO pins before you add AI.
Route 1: real-time object detection with an AI HAT+
This is the quickest way to see machine learning working on a Pi. These steps follow the Raspberry Pi AI documentation as of November 2026; check it for changes before you start.
- Fit the AI HAT+ to the Raspberry Pi 5 and connect a camera.
- Update the system and firmware: run
sudo apt update,sudo apt full-upgradeandsudo rpi-eeprom-update -a, then reboot. - Install the Hailo software:
sudo apt install dkmsand thensudo apt install hailo-all, then reboot. - Check the accelerator is found:
hailortcli fw-control identify. - Install the camera apps with
sudo apt install rpicam-appsand test the camera withrpicam-hello. - Run the YOLO object detection demo, which draws boxes and labels round things it recognises:
rpicam-hello -t 0 --post-process-file /usr/share/rpi-camera-assets/hailo_yolov8_inference.jsonYOLO (you only look once) is a family of object detection models that find and label many objects in each frame. The same pattern works for other demos such as pose estimation, and you can swap in your own compiled model later.
Route 2: running your own model on the CPU
For smaller jobs, such as classifying sensor readings, recognising a few spoken words or sorting simple images, the Pi's processor is enough. The usual workflow:
- Train on a computer. Build and train the model in Python with a framework such as TensorFlow or PyTorch, or use a ready trained one.
- Shrink it. Convert it to a compact format for small devices, such as LiteRT (Google's on-device runtime, built on TensorFlow Lite), and quantise it: store the weights as 8 bit integers instead of 32 bit decimals.
- Copy it to the Pi and install the matching runtime there.
- Feed it data from a camera, microphone or sensor in a loop, and act on the prediction, for example by lighting an LED through a GPIO pin.
Why quantising matters: a worked example
A model's size is roughly its number of weights times the bytes per weight. Take a model with 1 billion weights:
| Weight format | Bytes per weight | 1 billion weights | 3 billion weights |
|---|---|---|---|
| 32 bit float | 4 | 4 GB | 12 GB |
| 16 bit float | 2 | 2 GB | 6 GB |
| 8 bit integer | 1 | 1 GB | 3 GB |
| 4 bit integer | 0.5 | 0.5 GB | 1.5 GB |
That is why small devices use 8 bit or 4 bit models. A 3 billion weight language model stored at 4 bits takes about 1.5 GB, which fits in the AI HAT+ 2's 8 GB of memory with room to spare; the same model at 32 bits wouldn't fit at all. The cost is a small loss of accuracy.
Route 3: language models on a Raspberry Pi
Raspberry Pi says the AI HAT+ 2 can run large language models and vision language models locally, as well as speech to text and translation. Its documentation describes installing the Hailo software (hailo-h10-all), then the Gen AI model package, and starting hailo-ollama, which answers requests on a local web address. Models small enough for a Pi are far less capable than the big cloud chatbots, but they work offline and keep everything on the device. Our AI Models course explains how these models work inside.
Raspberry Pi machine learning project ideas
- Bird feeder camera that recognises which species visit and logs them.
- People counter for a doorway, using object detection.
- Gesture controlled lights using a pose estimation model and the GPIO pins.
- Offline voice assistant with speech to text and a small language model.
- Plant monitor that predicts when to water from soil and light sensor readings, a small model the CPU handles easily.
- Sorting machine that recognises objects, such as recycling, on a conveyor.
Common mistakes
- Trying to train big models on the Pi. Train on a computer or in the cloud and run the result on the Pi.
- Buying an AI HAT+ for an older Pi. The AI HAT+ boards only work with a Raspberry Pi 5. The AI Camera works with all models.
- Using a 32 bit operating system. The AI software needs 64-bit Raspberry Pi OS.
- Skipping the updates. The accelerator needs current firmware and drivers, so update before installing.
- Expecting cloud chatbot quality. Models that fit on a Pi are much smaller and less capable.
- No cooling. A hot Pi slows itself down, which looks like a slow model.
Common questions
Can a Raspberry Pi run machine learning?
Which Raspberry Pi is best for machine learning?
Can you run ChatGPT on a Raspberry Pi?
What is the difference between the AI HAT+ and the AI Camera?
Do I need to know Python?
Does machine learning on a Pi need the internet?
Revision cards
Read the front, say your answer, then flip to check.
Where to go next
- Solve it
Neural Network Trainer
Build a network and watch it learn in real time
Open the tool - Learn it
Raspberry Pi's
Build projects with the most popular single-board computer
Start the course