on
What You’ll Need
- Raspberry Pi 5 (8GB recommended)
- Raspberry Pi 5 AI KIT (option 1)
- Raspberry Pi M.2 M-Key HAT
- Hailo-8L M.2 M-Key module (Hailo-8 is also supported)
- Raspberry Pi 5 AI HAT (option 2)
- 26TOPs and 13TOPs are supported
- Active Cooler for the Raspberry Pi 5
If you haven’t done so already, be sure to force your Raspberry Pi 5 to use Gen 3 PCI Express settings. Follow this article for instructions on setting this up.
Ubuntu Requirements
Install the build-essential package
$ sudo apt install build-essential
Install the additional packages needed
$ sudo apt install bison flex libelf-dev dkms cmake pkg-config \ libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
Install the current Linux kernel headers
$ sudo apt install linux-headers-$(uname -r)
Install Python modules we’ll be using:
$ sudo apt install python3-pip python3-setuptools python3-venv
Install Tools
Download Samples
Setup our working directory.
$ cd $HOME $ mkdir -p github/hailo-ai $ cd github/hailo-ai
Clone the Raspberry Pi 5 Hailo Examples from GitHub:
$ git clone https://github.com/hailo-ai/hailo-rpi5-examples.git
Cloning into 'hailo-rpi5-examples'... remote: Enumerating objects: 487, done. remote: Counting objects: 100% (237/237), done. remote: Compressing objects: 100% (95/95), done. remote: Total 487 (delta 174), reused 142 (delta 142), pack-reused 250 (from 1) Receiving objects: 100% (487/487), 20.36 MiB | 1.29 MiB/s, done. Resolving deltas: 100% (275/275), done.
$ git clone https://github.com/hailo-ai/hailo_model_zoo
Cloning into 'hailo_model_zoo'...
remote: Enumerating objects: 8768, done.
remote: Counting objects: 100% (1980/1980), done.
remote: Compressing objects: 100% (943/943), done.
remote: Total 8768 (delta 1615), reused 1097 (delta 1031), pack-reused 6788 (from 1)
Receiving objects: 100% (8768/8768), 5.37 MiB | 808.00 KiB/s, done.
Resolving deltas: 100% (6819/6819), done.
Compile Hailo from Sources
Compiling Hailo PCIe Driver
From the
$HOME/github/hailoai
directory:git clone https://github.com/hailo-ai/hailort-drivers.git cd hailort-drivers
Cloning into 'hailort-drivers'... remote: Enumerating objects: 643, done. remote: Counting objects: 100% (125/125), done. remote: Compressing objects: 100% (92/92), done. remote: Total 643 (delta 49), reused 63 (delta 33), pack-reused 518 (from 1) Receiving objects: 100% (643/643), 1.98 MiB | 1.43 MiB/s, done. Resolving deltas: 100% (397/397), done.
Checkout the latest tagged release of driver:
$ git checkout tags/$(git tag -l --sort=-v:refname | head -1)
Note: switching to 'tags/v4.20.0'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by switching back to a branch. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -c with the switch command. Example: git switch -c <new-branch-name> Or undo this operation with: git switch - Turn off this advice by setting config variable advice.detachedHead to false HEAD is now at d1af769 v4.20.0 (#20)
Compile the driver
cd linux/pcie make all
make[1]: Entering directory '/usr/src/linux-headers-6.8.0-1017-raspi' warning: the compiler differs from the one used to build the kernel The kernel was built by: aarch64-linux-gnu-gcc-13 (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 You are using: gcc-13 (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 CC [M] /home/bmeyer/github.com/hailo-ai/hailort-drivers/linux/pcie/src/pcie.o CC [M] /home/bmeyer/github.com/hailo-ai/hailort-drivers/linux/pcie/src/fops.o CC [M] /home/bmeyer/github.com/hailo-ai/hailort-drivers/linux/pcie/src/sysfs.o CC [M] /home/bmeyer/github.com/hailo-ai/hailort-drivers/linux/pcie/src/nnc.o CC [M] /home/bmeyer/github.com/hailo-ai/hailort-drivers/linux/pcie/src/soc.o CC [M] /home/bmeyer/github.com/hailo-ai/hailort-drivers/linux/pcie/../../common/fw_validation.o CC [M] /home/bmeyer/github.com/hailo-ai/hailort-drivers/linux/pcie/../../common/fw_operation.o CC [M] /home/bmeyer/github.com/hailo-ai/hailort-drivers/linux/pcie/../../common/pcie_common.o CC [M] /home/bmeyer/github.com/hailo-ai/hailort-drivers/linux/pcie/../../common/vdma_common.o CC [M] /home/bmeyer/github.com/hailo-ai/hailort-drivers/linux/pcie/../../common/hailo_resource.o CC [M] /home/bmeyer/github.com/hailo-ai/hailort-drivers/linux/pcie/../utils/logs.o CC [M] /home/bmeyer/github.com/hailo-ai/hailort-drivers/linux/pcie/../vdma/vdma.o CC [M] /home/bmeyer/github.com/hailo-ai/hailort-drivers/linux/pcie/../vdma/memory.o CC [M] /home/bmeyer/github.com/hailo-ai/hailort-drivers/linux/pcie/../vdma/ioctl.o LD [M] /home/bmeyer/github.com/hailo-ai/hailort-drivers/linux/pcie/hailo_pci.o MODPOST /home/bmeyer/github.com/hailo-ai/hailort-drivers/linux/pcie/Module.symvers CC [M] /home/bmeyer/github.com/hailo-ai/hailort-drivers/linux/pcie/hailo_pci.mod.o LD [M] /home/bmeyer/github.com/hailo-ai/hailort-drivers/linux/pcie/hailo_pci.ko BTF [M] /home/bmeyer/github.com/hailo-ai/hailort-drivers/linux/pcie/hailo_pci.ko Skipping BTF generation for /home/bmeyer/github.com/hailo-ai/hailort-drivers/linux/pcie/hailo_pci.ko due to unavailability of vmlinux make[1]: Leaving directory '/usr/src/linux-headers-6.8.0-1017-raspi'
Install the Hailo PCIe Driver
Install the driver in
/lib/modules
$ sudo make install
make[1]: Entering directory '/usr/src/linux-headers-6.8.0-1017-raspi' INSTALL /lib/modules/6.8.0-1017-raspi/kernel/drivers/misc/hailo_pci.ko SIGN /lib/modules/6.8.0-1017-raspi/kernel/drivers/misc/hailo_pci.ko DEPMOD /lib/modules/6.8.0-1017-raspi Warning: modules_install: missing 'System.map' file. Skipping depmod. make[1]: Leaving directory '/usr/src/linux-headers-6.8.0-1017-raspi'
Load the driver (needs to be done once, after installation the driver will be loaded on boot)
sudo modprobe -v hailo_pci
insmod /lib/modules/6.8.0-1017-raspi/kernel/drivers/misc/hailo_pci.ko
Confirm the kernel module loaded properly:
```bash
$ lsmod | grep hailo_pci
```
```console
hailo_pci 118784 0
```
Download the Hailo PCIe Firmware
Download the firmware:
cd ../.. ./download_firmware.sh
--2025-01-06 09:36:08-- https://hailo-hailort.s3.eu-west-2.amazonaws.com/Hailo8/4.20.0/FW/hailo8_fw.4.20.0.bin Resolving hailo-hailort.s3.eu-west-2.amazonaws.com (hailo-hailort.s3.eu-west-2.amazonaws.com)... 52.95.148.78, 52.95.191.30, 52.95.149.6, ... Connecting to hailo-hailort.s3.eu-west-2.amazonaws.com (hailo-hailort.s3.eu-west-2.amazonaws.com)|52.95.148.78|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 166116 (162K) [binary/octet-stream] Saving to: ‘hailo8_fw.4.20.0.bin’ hailo8_fw.4.20.0.bin 100%[========================================================================================================>] 162.22K 667KB/s in 0.2s 2025-01-06 09:36:09 (667 KB/s) - ‘hailo8_fw.4.20.0.bin’ saved [166116/166116]
Move it into place:
$ sudo mkdir -p /lib/firmware/hailo $ sudo mv -v hailo8_fw.*.bin /lib/firmware/hailo/hailo8_fw.bin
renamed 'hailo8_fw.4.20.0.bin' -> '/lib/firmware/hailo/hailo8_fw.bin'
Copy udev rules into place:
$ sudo cp -v ./linux/pcie/51-hailo-udev.rules /etc/udev/rules.d/
'./linux/pcie/51-hailo-udev.rules' -> '/etc/udev/rules.d/51-hailo-udev.rules'
Apply the changes with:
$ sudo udevadm control --reload-rules && sudo udevadm trigger
Compiling HailoRT
From the
$HOME/github/hailoai
directory:git clone https://github.com/hailo-ai/hailort.git cd hailort
Cloning into 'hailort'... remote: Enumerating objects: 5763, done. remote: Counting objects: 100% (731/731), done. remote: Compressing objects: 100% (621/621), done. remote: Total 5763 (delta 154), reused 304 (delta 103), pack-reused 5032 (from 2) Receiving objects: 100% (5763/5763), 6.62 MiB | 4.06 MiB/s, done. Resolving deltas: 100% (3303/3303), done.
Checkout the latest tagged release of driver:
$ git checkout tags/$(git tag -l --sort=-v:refname | head -1)
Note: switching to 'tags/v4.20.0'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by switching back to a branch. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -c with the switch command. Example: git switch -c <new-branch-name> Or undo this operation with: git switch - Turn off this advice by setting config variable advice.detachedHead to false HEAD is now at 542ba8f v4.20.0 (#22)
Compile the source
$ cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && sudo cmake --build build --config release install
Install the HailoRT code
$ cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && sudo cmake --build build --config release --target install
Install the Python bindings
Compile the Python bindings
$ pushd hailort/libhailort/bindings/python/platform/
~/github.com/hailo-ai/hailort/hailort/libhailort/bindings/python/platform ~/github.com/hailo-ai/hailort
python3 setup.py bdist_wheel --plat-name=linux_aarch64 popd
Compile the hailort-gstreamer-binding:
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DHAILO_BUILD_GSTREAMER=1 && cmake --build build --config release --target gsthailo
Compile the hailort-examples:
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DHAILO_BUILD_EXAMPLES=1 && cmake --build build --config release --target hailort_examples
Validate the PCIe Driver was Successfully Installed
Make sure your device is connected to a PCIe/M.2/mPCIe slot:
lspci | grep Co-processor
The expected output is:
0000:01:00.0 Co-processor: Hailo Technologies Ltd. Hailo-8 AI Processor (rev 01)
If you see an unidentified device, for example:
0000:01:00.0 Co-processor: Device 1e60:2864 (rev 01)
then update the PCIe IDs list with:
sudo update-pciids
If the Hailo device does not appear in the result, ensure the following:
- The device is connected properly to the slot.
- The PCIe driver installation did not output any error messages.
- The machine was rebooted after installing the PCIe driver.
- The PCIe slot is working properly.
$ hailortcli scan
Hailo Devices:
[-] Device: 0000:01:00.0
$ hailortcli fw-control identify
Executing on device: 0000:01:00.0
Identifying board
Control Protocol Version: 2
Firmware Version: 4.20.0 (release,app,extended context switch buffer)
Logger Version: 0
Board Name: Hailo-8
Device Architecture: HAILO8
Serial Number: <N/A>
Part Number: <N/A>
Product Name: <N/A>
sudo apt install python3-venv