YOLOv11 environment setup1. Preliminary preparation2. Install PyTorch3. Install Ultralytics4. Verify the installationReferences
This chapter is for self-build using the official image of Raspberry Pi 5B. If you are using the YAHBOOM version of the image, this tutorial can be ignored.
sudo apt update
sudo apt install python3-pip -y
sudo pip install -U pip
The official download address is: https://download.pytorch.org/whl/torch_stable.html
If you download it yourself, you need to find the corresponding torch and torchvision versions.
This experiment downloads torch-2.1.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl and torchvision-0.16.2-cp311-cp311-linux_aarch64.whl
The above two files can be obtained from the attachment and transferred to the Raspberry Pi via winSCP
Installation command:
xpip3 install torch-2.1.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
pip3 install torchvision-0.16.2-cp311-cp311-linux_aarch64.whl
xxxxxxxxxx
sudo pip3 install ultralytics[export]
You also need to update Ultralytics to the latest version, otherwise you will get an error AttributeError: Can't get attribute 'C3k2' on <module 'ultralytics.nn.modules.block' from '/home/pi/.local/lib/python3.11/site-packages/ultralytics/nn/modules/block.py'>
xxxxxxxxxx
pip install --upgrade ultralytics
Install onnxruntime
xxxxxxxxxx
pip3 install onnxruntime
Note: Using onnxruntime requires installing a specific version of numpy. If it is not 1.23.5, you can run the following command to install the specified version
xxxxxxxxxx
sudo pip3 install numpy==1.23.5
Restart afterwards
xxxxxxxxxx
sudo reboot
Verify Ultralytics
xxxxxxxxxx
python3 -c "import ultralytics; print(ultralytics.__version__)"
Verify Torch
xxxxxxxxxx
python3 -c "import torch; print(torch.__version__); print(torch.cuda.is_available())"
Verify Torchvision
xxxxxxxxxx
python3 -c "import torchvision; print(torchvision.__version__)"
Verify Numpy
xxxxxxxxxx
python3 -c "import numpy; print(numpy.__version__)"
Note: The ultralytics version will be updated later, please refer to the version information queried in the system