ultralytics / hub

Ultralytics HUB tutorials and support
https://hub.ultralytics.com
GNU Affero General Public License v3.0
125 stars 11 forks source link

pip install ultralytics on Raspberry Pi 4 #787

Open rspandolfi opened 1 month ago

rspandolfi commented 1 month ago

There may be a newly emergent problem with pip install ultralytics on Raspberry Pi 4. Following installation when running yolo, the Raspberry Pi responds with "illegal instruction." This may indicate that a version of YOLO was installed that is not compatible with the Raspberry Pi processor.

rspandolfi commented 1 month ago

Hi Paula,

Thanks for the comprehensive guidance. We are working with fresh operating systems (64-bit Bookworm), current Python version, and virtual environment. Options #1,2,3,5 are not relevant to our build. Option #4 seems to be relevant.

As we have run into difficulties with YOLO installations on Raspberry Pi in the past due to: (1) incompatible versions of PyTorch; (2) incompatible versions of Torchvision; and (3) incompatible versions of YOLO, I do have a few questions that might help us better respond to these issues.

Is there a way to query the version of PyTorch and Torchvision that are installed with pip3 install ultralytics and is there a way to determine if these are compatible with the Raspberry Pi Operating System that is installed on the Raspberry Pi?

Is there a way to query the compatible processors for the version of YOLO that is installed with pip3 install ultralytics? Is there a way to query the processer in the Raspberry Pi to check if it is compatible?

Does pip install ultralytics query the processor and then install the correct code?

How does that differ from git clone followed by pip install -e?

Are you suggesting that I build from source, compile from source, or install from source? How do these differ?

Thanks,

Ron

glenn-jocher commented 1 month ago

@rspandolfi for a Raspberry Pi compatible image that is CI tested every 24 hours with YOLOv8 see https://github.com/ultralytics/ultralytics/blob/main/docker/Dockerfile-arm64

glenn-jocher commented 1 month ago

From https://github.com/ultralytics/ultralytics/actions/runs/10189603916/job/28187949674

Screenshot 2024-08-01 at 11 42 56
rspandolfi commented 1 month ago

The newly emergent problem with pip install ultralytics on Raspberry Pi 4 has been resolved. It was caused by incompatible versions of torch and torchvision being installed with pip install ultralytics. The problem is resolved by the following:

pip uninstall torch pip uninstall torchvision pip install torch==2.0.1 pip install torchvision=0.15.2

The above versions of torch and torchvsion are compatible with the Raspberry Pi 3 and Raspberry Pi 4, but they may not be the most current compatible versions.

There will be times when pip install ultralytics will install compatible versions of torch and torchvision, and there will be times when it will not. Within Kashmir World Foundation, we will continue to use the quick and easy pip install ultralytics, and if yolo fails to run with "illegal instruction," then we will uninstall and install compatible versions of torch and torchvision.

The guidance offered by Paula and Glenn was extremely helpful in resolving the problem. Our interns from around the world (https://www.kashmirworldfoundation.org/internships) and the professional field biologists, conservationists, and law enforcement specialists that use our products, all will benefit directly or indirectly from your dedication and expertise.