دليل البدء السريع: Raspberry Pi مع Ultralytics YOLO26
يُعد Raspberry Pi كمبيوترًا صغيرًا ومنخفض التكلفة يشغّل Ultralytics YOLO26 لتنفيذ كشف الكائنات آنيًا على الأجهزة الطرفية، دون الحاجة إلى GPU. يشرح هذا الدليل خطوات نشر YOLO26 على Raspberry Pi 4 و5: تثبيت نظام التشغيل على بطاقة، وتثبيت Ultralytics، والتصدير إلى NCNN لتحقيق أسرع استدلال على ARM، وتنفيذ التنبؤات على بث مباشر من الكاميرا. كما يتضمن معايير أداء عبر ثمانية تنسيقات تصدير لمساعدتك على اختيار أفضل موازنة بين السرعة والدقة بما يلائم أجهزتك.
انتقل إلى إعداد Ultralytics، أو التصدير إلى NCNN وتشغيل الاستدلال، أو الاختبارات المعيارية، أو الاستدلال باستخدام الكاميرا.
شاهد: تحديثات وتحسينات Raspberry Pi 5.
اختُبر هذا الدليل على Raspberry Pi 4 وRaspberry Pi 5 اللذين يعملان بأحدث إصدار من Raspberry Pi OS Bookworm (Debian 12). يُتوقع أن يعمل هذا الدليل على أجهزة Raspberry Pi الأقدم، مثل Raspberry Pi 3، ما دام نظام Raspberry Pi OS Bookworm نفسه مثبتًا.
ما هو Raspberry Pi؟#
Raspberry Pi كمبيوتر أحادي اللوحة صغير ومنخفض التكلفة. وقد أصبح شائعًا في مجموعة واسعة من المشاريع والتطبيقات، بدءًا من أتمتة المنازل للهواة وصولًا إلى الاستخدامات الصناعية. تستطيع لوحات Raspberry Pi تشغيل أنظمة تشغيل متنوعة، وتوفر منافذ GPIO (الإدخال/الإخراج للأغراض العامة) التي تتيح التكامل بسهولة مع المستشعرات والمشغلات ومكونات الأجهزة الأخرى. تتوفر اللوحات بطرازات مختلفة ومواصفات متنوعة، لكنها تشترك جميعًا في فلسفة التصميم الأساسية نفسها: منخفضة التكلفة، وصغيرة الحجم، ومتعددة الاستخدامات.
مقارنة بين طرازات Raspberry Pi#
| Raspberry Pi 3 | Raspberry Pi 4 | Raspberry Pi 5 | |
|---|---|---|---|
| CPU | Broadcom BCM2837، نظام على شريحة Cortex-A53 64Bit | Broadcom BCM2711، نظام على شريحة Cortex-A72 64Bit | Broadcom BCM2712، نظام على شريحة Cortex-A76 64Bit |
| أقصى تردد لـ CPU | 1.4GHz | 1.8GHz | 2.4GHz |
| GPU | VideoCore IV | VideoCore VI | VideoCore VII |
| أقصى تردد لـ GPU | 400MHz | 500MHz | 800MHz |
| الذاكرة | ذاكرة SDRAM من نوع LPDDR2 بسعة 1GB | ذاكرة SDRAM من نوع LPDDR4-3200 بسعات 1GB و2GB و4GB و8GB | ذاكرة SDRAM من نوع LPDDR4X-4267 بسعات 2GB و4GB و8GB و16GB |
| PCIe | غير متاح | غير متاح | واجهة PCIe 2.0 واحدة |
| أقصى استهلاك للطاقة | 2.5A@5V | 3A@5V | 5A@5V (مع تفعيل PD) |
ما هو Raspberry Pi OS؟#
Raspberry Pi OS (المعروف سابقًا باسم Raspbian) هو نظام تشغيل شبيه بـ Unix، يستند إلى توزيعة Debian GNU/Linux لعائلة Raspberry Pi من الحواسيب الصغيرة ذات اللوحة الواحدة، التي توزعها مؤسسة Raspberry Pi Foundation. جرى تحسين Raspberry Pi OS بدرجة كبيرة للعمل على Raspberry Pi المزود بوحدات معالجة مركزية ARM، ويستخدم بيئة سطح مكتب خفيفة تعمل افتراضيًا على Wayland في Raspberry Pi 4 و5. يخضع Raspberry Pi OS لتطوير مستمر، مع التركيز على تحسين استقرار أكبر عدد ممكن من حزم Debian وأدائها على Raspberry Pi.
تثبيت Raspberry Pi OS على Raspberry Pi#
أول ما ينبغي فعله بعد الحصول على Raspberry Pi هو تثبيت نظام Raspberry Pi OS على بطاقة micro-SD، وإدخالها في الجهاز، ثم تشغيل النظام. اتبع وثائق البدء من Raspberry Pi المفصلة لتجهيز جهازك للاستخدام لأول مرة.
إعداد Ultralytics#
يمكنك إعداد حزمة Ultralytics على Raspberry Pi بطريقتين لمشروع الرؤية الحاسوبية التالي:
البدء باستخدام Docker#
أسرع طريقة لبدء استخدام Ultralytics YOLO26 على Raspberry Pi هي تشغيل صورة Docker جاهزة لـ Raspberry Pi.
نفّذ الأمر أدناه لسحب حاوية Docker وتشغيلها على Raspberry Pi. تستند هذه الحاوية إلى صورة Python الرسمية 3.13-slim، التي تشغّل Python 3.13 على أحدث إصدار من Debian.
t=ultralytics/ultralytics:latest-arm64
sudo docker pull $t && sudo docker run -it --ipc=host $tتتضمن صورة Docker حزمة Ultralytics مسبقًا، لذا يمكنك الانتقال مباشرةً إلى تصدير نموذجك إلى NCNN.
البدء دون Docker#
تثبيت حزمة Ultralytics#
سنثبّت هنا حزمة Ultralytics على Raspberry Pi. تُثبّت تبعيات التصدير لتنسيقات مثل NCNN تلقائيًا عند تصدير نموذج PyTorch للمرة الأولى، لذا لا نحتاج هنا إلا إلى الحزمة الأساسية.
-
حدّث قائمة الحزم، وثبّت pip، ثم رقِّه إلى أحدث إصدار
sudo apt update sudo apt install python3-pip -y pip install -U pip -
ثبّت حزمة pip المسماة
ultralyticspip install ultralytics -
أعِد تشغيل الجهاز
sudo reboot
استخدام NCNN على Raspberry Pi#
من بين جميع تنسيقات التصدير التي يدعمها Ultralytics، يوفر NCNN أفضل أداء للاستدلال على أجهزة Raspberry Pi، لأنه محسّن بدرجة كبيرة للمنصات المحمولة والمضمنة مثل ARM. حوّل نموذج YOLO26n بتنسيق PyTorch إلى NCNN، ثم نفّذ الاستدلال باستخدام النموذج المُصدّر:
from ultralytics import YOLO
# تحميل نموذج YOLO26n بصيغة PyTorch
model = YOLO("yolo26n.pt")
# تصدير النموذج بتنسيق NCNN
model.export(format="ncnn") # creates 'yolo26n_ncnn_model'
# تحميل نموذج NCNN المُصدَّر
ncnn_model = YOLO("yolo26n_ncnn_model")
# تنفيذ الاستدلال
results = ncnn_model("https://ultralytics.com/images/bus.jpg")لمزيد من التفاصيل حول خيارات التصدير المدعومة، راجع دليل خيارات نشر النموذج.
تحسينات أداء YOLO26 مقارنةً بـ YOLO11#
صُمم YOLO26 خصيصًا للعمل على الأجهزة محدودة الموارد مثل Raspberry Pi 5. مقارنةً بـ YOLO11n، يحقق YOLO26n زيادة ~15% في FPS (6.79 → 7.79)، إلى جانب mAP أعلى (40.1 مقابل 39.5) عند حجم إدخال 640، باستخدام نماذج مُصدّرة بتنسيق ONNX على Raspberry Pi 5. يوضح الجدول والمخطط أدناه هذه المقارنة.
| النموذج | mAP50-95(B) | وقت الاستدلال (ms/im) |
|---|---|---|
| YOLO26n | 40.1 | 128.42 |
| YOLO26s | 47.8 | 352.84 |
| YOLO26m | 52.5 | 993.78 |
| YOLO26l | 54.4 | 1259.46 |
| YOLO26x | 56.9 | 2636.26 |
تم قياس الأداء باستخدام Ultralytics 8.4.14.
معايير أداء YOLO26 على Raspberry Pi 5#
أجرى فريق Ultralytics اختبارات أداء YOLO26 على ثمانية تنسيقات مختلفة للنماذج، مع قياس السرعة والدقة: PyTorch وTorchScript وONNX وOpenVINO وLiteRT وMNN وNCNN وExecuTorch. أُجريت الاختبارات على Raspberry Pi 5 بدقة FP32 وبحجم صورة الإدخال الافتراضي 640.
رسم بياني للمقارنة#
يتضمن الاختبار YOLO26n وYOLO26s فقط، لأن أحجام النماذج الأكبر تعمل ببطء شديد على Raspberry Pi ولا تصلح للاستخدام العملي.
جدول مقارنة مفصل#
يعرض الجدول أدناه نتائج قياس الأداء لنموذجين مختلفين (YOLO26n وYOLO26s) عبر ثمانية تنسيقات مختلفة (PyTorch وTorchScript وONNX وOpenVINO وLiteRT وMNN وNCNN وExecuTorch)، عند التشغيل على Raspberry Pi 5، موضحًا الحالة والحجم ومقياس mAP50-95(B) وزمن الاستدلال لكل تركيبة.
| التنسيق | الحالة | الحجم على القرص (MB) | mAP50-95(B) | وقت الاستدلال (ms/im) |
|---|---|---|---|---|
| PyTorch | ✅ | 5.3 | 0.4760 | 299.09 |
| TorchScript | ✅ | 9.8 | 0.4734 | 353.20 |
| ONNX | ✅ | 9.5 | 0.4734 | 125.99 |
| OpenVINO | ✅ | 9.6 | 0.4734 | 104.55 |
| LiteRT | ✅ | 9.8 | 0.4730 | 123.30 |
| MNN | ✅ | 9.4 | 0.4749 | 91.87 |
| NCNN | ✅ | 9.4 | 0.4784 | 67.03 |
| ExecuTorch | ✅ | 9.4 | 0.4772 | 144.83 |
تم قياس الأداء باستخدام Ultralytics 8.4.108
لا يشمل وقت الاستدلال المعالجة المسبقة أو اللاحقة.
إعادة إنتاج نتائجنا#
لإعادة إجراء اختبارات أداء Ultralytics أعلاه على جميع تنسيقات التصدير، شغّل هذا الرمز:
from ultralytics import YOLO
# تحميل نموذج YOLO26n بصيغة PyTorch
model = YOLO("yolo26n.pt")
# اختبر سرعة YOLO26n ودقته على مجموعة البيانات COCO128 بجميع تنسيقات التصدير
results = model.benchmark(data="coco128.yaml", imgsz=640)لاحظ أن نتائج الاختبارات المعيارية قد تختلف بحسب تكوين الأجهزة والبرامج الدقيق للنظام، وكذلك بحسب الحمل الحالي على النظام عند تشغيل الاختبارات. للحصول على نتائج موثوقة قدر الإمكان، استخدم مجموعة بيانات تحتوي على عدد كبير من الصور، مثل data='coco.yaml' (5000 صورة تحقق).
لا يتوفر تصدير format=litert (عبر litert-torch) إلا على Linux x86_64 وmacOS، وليس على Raspberry Pi نفسه. صدّر نموذج .tflite على جهاز Linux x86_64 أو Mac، وانقله إلى Raspberry Pi، ثم استخدم Pi للاستدلال.
استخدام كاميرا Raspberry Pi#
غالبًا ما تحتاج مشاريع الرؤية الحاسوبية على Raspberry Pi إلى تدفقات فيديو آنية لإجراء الاستدلال. يتيح موصل MIPI CSI المدمج في Raspberry Pi توصيل وحدات كاميرا Raspberry Pi الرسمية. استخدمنا في هذا الدليل وحدة كاميرا Raspberry Pi 3 لالتقاط تدفقات الفيديو وإجراء الاستدلال باستخدام نماذج YOLO26.
تعرّف على المزيد حول وحدات الكاميرا المختلفة التي توفرها Raspberry Pi، وكذلك كيفية البدء باستخدام وحدات كاميرا Raspberry Pi.
يستخدم Raspberry Pi 5 موصلات CSI أصغر من تلك الموجودة في Raspberry Pi 4 (22 سنًا مقابل 15 سنًا)، لذا ستحتاج إلى كابل محول من 15 سنًا إلى 22 سنًا لتوصيل كاميرا Raspberry Pi.
اختبار الكاميرا#
نفّذ الأمر rpicam-hello التالي بعد توصيل الكاميرا بـ Raspberry Pi. من المفترض أن ترى بث فيديو مباشرًا من الكاميرا لمدة 5 ثوانٍ تقريبًا.
rpicam-helloالاستدلال باستخدام الكاميرا#
توجد طريقتان لاستخدام كاميرا Raspberry Pi لإجراء الاستدلال على نماذج YOLO26.
استخدم picamera2، المثبت مسبقًا مع Raspberry Pi OS، للوصول إلى الكاميرا وتنفيذ الاستدلال باستخدام نماذج YOLO26.
import cv2
from picamera2 import Picamera2
from ultralytics import YOLO
# تهيئة Picamera2
picam2 = Picamera2()
picam2.preview_configuration.main.size = (1280, 720)
picam2.preview_configuration.main.format = "RGB888"
picam2.preview_configuration.align()
picam2.configure("preview")
picam2.start()
# تحميل نموذج YOLO26
model = YOLO("yolo26n.pt")
while True:
# التقاط الإطارات واحدًا تلو الآخر
frame = picam2.capture_array()
# إجراء استدلال YOLO26 على الإطار
results = model(frame)
# تصور النتائج على الإطار
annotated_frame = results[0].plot()
# عرض الإطار الناتج
cv2.imshow("Camera", annotated_frame)
# إنهاء الحلقة إذا ضُغط على 'q'
if cv2.waitKey(1) == ord("q"):
break
# تحرير الموارد وإغلاق النوافذ
cv2.destroyAllWindows()أفضل الممارسات عند استخدام Raspberry Pi#
اتبع أفضل الممارسات التالية لتحقيق أقصى أداء لـ YOLO26 على Raspberry Pi.
-
استخدم SSD
للتشغيل المتواصل على مدار الساعة طوال أيام الأسبوع، استخدم SSD للنظام، إذ قد تتآكل بطاقة SD أو تتعطل بسبب عمليات الكتابة المستمرة. وباستخدام موصل PCIe المدمج في Raspberry Pi 5، يمكنك توصيل أقراص SSD عبر محول مثل NVMe Base for Raspberry Pi 5.
-
التثبيت دون واجهة رسومية
عند تثبيت Raspberry Pi OS، يمكنك اختيار عدم تثبيت بيئة سطح المكتب (Raspberry Pi OS Lite)، ما يوفر قدرًا من ذاكرة RAM على الجهاز ويتيح مساحة أكبر لمعالجة الرؤية الحاسوبية.
-
رفع تردد Raspberry Pi
إذا أردت زيادة طفيفة في الأداء عند تشغيل نماذج Ultralytics YOLO26 على Raspberry Pi 5، يمكنك رفع تردد CPU من قيمته الأساسية البالغة 2.4GHz إلى 3.0GHz، ورفع تردد GPU من 800MHz إلى 1GHz. إذا أصبح النظام غير مستقر أو تعطل، فاخفض قيم رفع التردد بمقدار 100MHz في كل مرة. احرص على توفير تبريد مناسب، إذ يزيد رفع التردد من توليد الحرارة وقد يؤدي إلى خفض التردد حراريًا.
أ. حدّث البرنامج
sudo apt update && sudo apt dist-upgradeب. افتح ملف الإعدادات لتحريره
sudo nano /boot/firmware/config.txtج. أضف الأسطر التالية في النهاية
arm_freq=3000 gpu_freq=1000 force_turbo=1د. احفظ واخرج بالضغط على CTRL + X، ثم Y، ثم ENTER
هـ. أعد تشغيل Raspberry Pi
الخطوات التالية#
لقد أعددت YOLO26 بنجاح على Raspberry Pi. لمتابعة التعمق، استكشف وضع التنبؤ لمزيد من خيارات الاستدلال، أو وضع التصدير لمزيد من تنسيقات النشر، أو دليل NVIDIA Jetson إذا كنت بحاجة إلى قدرة حوسبة أكبر على الحافة. للاطلاع على الوثائق الكاملة، تفضّل بزيارة وثائق Ultralytics YOLO26.
الشكر والاقتباسات#
أُعد هذا الدليل في الأصل بواسطة Daan Eeltink لصالح Kashmir World Foundation، وهي مؤسسة مكرسة لاستخدام YOLO في الحفاظ على الأنواع المهددة بالانقراض. ونُقدّر عمل المؤسسة الريادي وتركيزها التعليمي في مجال تقنيات اكتشاف الأجسام.
لمزيد من المعلومات حول أنشطة Kashmir World Foundation، يمكنك زيارة موقعها الإلكتروني.
الأسئلة الشائعة#
لإعداد Ultralytics YOLO26 على Raspberry Pi دون Docker، اتبع الخطوات التالية:
- حدّث قائمة الحزم وثبّت
pip:sudo apt update sudo apt install python3-pip -y pip install -U pip - ثبّت حزمة Ultralytics:
pip install ultralytics - أعد تشغيل الجهاز لتطبيق التغييرات:
sudo reboot
للاطلاع على التعليمات المفصلة، راجع قسم البدء دون Docker.
- حدّث قائمة الحزم وثبّت
يتميز NCNN بتحسينات كبيرة للمنصات المحمولة والمضمنة، ما يجعله خيارًا قويًا لتشغيل YOLO26 على أجهزة Raspberry Pi. وتوفر نوى المعالجة المحسّنة لمعمارية ARM استدلالًا أسرع على Pi مقارنةً بصيغ التصدير الأخرى في المعايير أعلاه.
يمكنك تحويل نموذج YOLO26 بصيغة PyTorch إلى تنسيق NCNN باستخدام أوامر Python أو CLI:
مثالfrom ultralytics import YOLO # تحميل نموذج YOLO26n بصيغة PyTorch model = YOLO("yolo26n.pt") # تصدير النموذج بتنسيق NCNN model.export(format="ncnn") # creates 'yolo26n_ncnn_model' # تحميل نموذج NCNN المُصدَّر ncnn_model = YOLO("yolo26n_ncnn_model") # تنفيذ الاستدلال results = ncnn_model("https://ultralytics.com/images/bus.jpg")لمزيد من التفاصيل، راجع قسم استخدام NCNN على Raspberry Pi.
تشمل الفروق الرئيسية ما يلي:
- CPU: يستخدم Raspberry Pi 4 نظامًا على شريحة Broadcom BCM2711 بمعمارية Cortex-A72 64-bit، بينما يستخدم Raspberry Pi 5 نظامًا على شريحة Broadcom BCM2712 بمعمارية Cortex-A76 64-bit.
- أقصى تردد لـ CPU: يبلغ الحد الأقصى للتردد في Raspberry Pi 4 مقدار 1.8GHz، بينما يصل في Raspberry Pi 5 إلى 2.4GHz.
- الذاكرة: توفر Raspberry Pi 4 ذاكرة SDRAM من نوع LPDDR4-3200 بسعة تصل إلى 8GB، بينما يأتي Raspberry Pi 5 بذاكرة SDRAM من نوع LPDDR4X-4267، والمتوفرة بإصدارات بسعات 2GB و4GB و8GB و16GB.
تسهم هذه التحسينات في تحقيق نتائج أفضل في اختبارات أداء نماذج YOLO26 على Raspberry Pi 5 مقارنةً بـ Raspberry Pi 4. راجع جدول مقارنة سلسلة Raspberry Pi لمزيد من التفاصيل.
توجد طريقتان لإعداد كاميرا Raspberry Pi لاستدلال YOLO26:
-
باستخدام
picamera2:import cv2 from picamera2 import Picamera2 from ultralytics import YOLO picam2 = Picamera2() picam2.preview_configuration.main.size = (1280, 720) picam2.preview_configuration.main.format = "RGB888" picam2.preview_configuration.align() picam2.configure("preview") picam2.start() model = YOLO("yolo26n.pt") while True: frame = picam2.capture_array() results = model(frame) annotated_frame = results[0].plot() cv2.imshow("Camera", annotated_frame) if cv2.waitKey(1) == ord("q"): break cv2.destroyAllWindows() -
باستخدام دفق TCP:
rpicam-vid -n -t 0 --inline --listen -o tcp://127.0.0.1:8888from ultralytics import YOLO model = YOLO("yolo26n.pt") results = model("tcp://127.0.0.1:8888")
للحصول على إرشادات الإعداد التفصيلية، تفضل بزيارة قسم الاستدلال باستخدام الكاميرا.
-
التعليقات134
اطرح سؤالًا، وشارك نتائجك، أو ساعد شخصًا آخر.
smhty
Works great on Raspberry Pi 5. A tutorial for the AI kit that comes with Raspberry Pi 5 would be great as well: https://www.raspberrypi.com/products/ai-kit/
1
Glenn JocherUltralytics(تم التعديل)Hi there!
Thank you for your feedback and for sharing your positive experience on the Raspberry Pi 5! 😊
Creating a tutorial for the AI kit that comes with the Raspberry Pi 5 is a fantastic idea. In the meantime, you can refer to our comprehensive Quick Start Guide for Raspberry Pi with Ultralytics YOLO26, which provides detailed instructions on setting up and running YOLO on Raspberry Pi devices, including performance benchmarks.
For those interested in using the AI kit, the setup process should be quite similar. Here’s a quick overview to get you started:
-
Flash Raspberry Pi OS: Ensure you have the latest Raspberry Pi OS Bookworm (Debian 12) installed. Follow the Getting Started Documentation by Raspberry Pi to prepare your device.
-
Set Up Ultralytics:
- With Docker:
t=ultralytics/ultralytics:latest-arm64 && sudo docker pull $t && sudo docker run -it --ipc=host $t - Without Docker:
sudo apt update sudo apt install python3-pip -y pip install -U pip pip install ultralytics[export] sudo reboot
- With Docker:
-
Use NCNN for Best Performance: Convert your YOLO26 model to NCNN format for optimal performance on Raspberry Pi:
from ultralytics import YOLO # Load a YOLO26n PyTorch model model = YOLO("yolo26n.pt") # Export the model to NCNN format model.export(format="ncnn") # creates 'yolo26n_ncnn_model' # Load the exported NCNN model ncnn_model = YOLO("yolo26n_ncnn_model") # Run inference results = ncnn_model("https://ultralytics.com/images/bus.jpg") -
Using the Raspberry Pi Camera: For real-time video feeds, you can use the
picamera2library or set up a TCP stream:-
Using
picamera2:import cv2 from picamera2 import Picamera2 from ultralytics import YOLO picam2 = Picamera2() picam2.preview_configuration.main.size = (1280, 720) picam2.preview_configuration.main.format = "RGB888" picam2.preview_configuration.align() picam2.configure("preview") picam2.start() model = YOLO("yolo26n.pt") while True: frame = picam2.capture_array() results = model(frame) annotated_frame = results[0].plot() cv2.imshow("Camera", annotated_frame) if cv2.waitKey(1) == ord("q"): break cv2.destroyAllWindows() -
Using TCP Stream:
rpicam-vid -n -t 0 --inline --listen -o tcp://127.0.0.1:8888from ultralytics import YOLO model = YOLO("yolo26n.pt") results = model("tcp://127.0.0.1:8888")
-
We hope this helps you get started with the AI kit on your Raspberry Pi 5. For more detailed instructions and additional resources, please visit our Raspberry Pi Guide.
Happy coding! 🚀
-
wnelis
Today I've installed module ultralytics on a Raspberry Pi 4 with 4 [GiB] memory running Trixie. Some remarks about what I've learned: . Use the 64-bit variant of Raspberry OS; . Use an microSD card of at least 32 [GiB]; . Disable /tmp becoming a file system in memory (tmpfs):
sudo systemctl mask tmp.mount; . OpenCV is installed using apt, module ultralytics is installed in a virtual Python environment: 'python -m venv --system-site-packages `.It is found that YOLO runs into a hardware error: "Illegal instruction". This can be reproduced by using the Python script shown above to export the model in NCNN format. The output is:
Downloading https://github.com/ultralyti…: 100% ━━━━━━━━━━━━ 5.3MB 1.4MB/s 3.8s Ultralytics 8.4.191 🚀 Python-3.13.5 torch-2.14.1+cu130 CPU (aarch64) Illegal instruction
How can this issue be solved?
Paula DerrengerUltralytics@wnelis the most likely cause is a native PyTorch binary using instructions unsupported by the Pi 4’s CPU, rather than faulty hardware; similar crashes are documented in Ultralytics #19091 and upstream PyTorch, although your exact version is not confirmed affected. (github.com) Your log shows a CUDA build (
+cu130); first replace it with the matching official CPU-only packages inside your activated virtual environment, then retry the export: (pytorch.org)python -m pip install --force-reinstall torch==2.14.1 torchvision==0.29.1 --index-url https://download.pytorch.org/whl/cpuIf it still crashes, please share the text output of
yolo checksandpython -m pip show torch torchvisionfrom that same environment so we can identify package/path conflicts.
hm-zeroone(تم التعديل)
"We haven’t validated Orbit OS yet, but if it supports tflite or onnx runtimes you should be able to deploy an exported Ultralytics YOLO26 model there using Export mode and the deployment options guide; if you try it, please share the exact device, export format, and any text error logs here in Discussions so the Ultralytics team can take a look."
Hi @glenn-jocher,
I added a new feature to my Orbit OS app to test YOLO models directly on edge devices, in this case a Raspberry Pi. The app now allows adding new models, and by default includes YOLO v8, v11 and v26.
We also introduced a benchmark mode, where you can select an image and run all models to compare performance and results.
In the example shown in the image, YOLOv8 achieved the highest number of correct object detections by time.
This demo video shows the remote deployment, no SSH, no Docker, of the app in action on Raspberry Pi 5 vs Arduino UNO Q and a comparison (“VS”) between the RPi 5 and UNO Q running YOLO v8. https://youtu.be/aiFJmosYVAI?si=v3Jo_TbswU3n-sZU
Glenn JocherUltralyticsThanks for sharing the Orbit OS benchmark; for a fair cross-model comparison please include the exact export/runtime backend,
imgsz, confidence/IoU thresholds, and per-image latency/FPS, since on Raspberry Pi CPU deployments NCNN is usually the best baseline for YOLO26.hm-zeroone(تم التعديل)
Hey! Thanks for the feedback. All models were tested under the same conditions — TFlite runtime, same image, same thresholds (conf=0.50, IoU=0.45), same imgsz 640×640 with letterbox preprocessing.
Everything runs through the OrbitOS SDK which currently has TFLite and ONNX embedded. NCNN is something we'll look into adding in a future release.
Quick question — for RPi deployments, would you recommend INT8 or float16 as the default export format?
Orbit OS SDK 26.0.1 Inference example.
Orbit OS is multi-language — For now only Go SDK is available, Python, Java and C++ SDKs are coming soon.
model, _ := device.AIManager.UploadAndLoadModel( "yolo8n", "models/yolo26n_float16.tflite", aiv26.ModelBackend_TFLITE, aiv26.ExecutionMode_EXEC_HIGH_THREADS, ) resp, _ := model.Infer(ctx, tensor.Data, tensor.Shape, tensor.Dtype) fmt.Println(resp.GetOutputShape()) // [1 84 8400] fmt.Println(resp.GetLatencyUs()) // e.g. 528000
Glenn JocherUltralytics(تم التعديل)For plain Raspberry Pi CPU deployment with
LiteRT(.tflite), I’d usually default toINT8for the best speed and memory savings, and usefloat16only if quantization hurts accuracy too much or your runtime performs better with FP kernels; if you benchmark both, the LiteRT export guide is the right reference, while our Raspberry Pi guide showsNCNNas the strongest baseline once you add that backend.1
safdarhamid64-cpu
when i write in raspberry pi terminal : from ultralytics import yolo error msg illegal instruction pops up , i have trained model and even i have first created environment and installed pip install ultralytics but still i am not able to run model yolo11n on my Raspberry Pi 4 , Guide me plzz
Glenn JocherUltralyticsThat
Illegal instructionon Raspberry Pi usually means an incompatible binary wheel (most oftentorch/numpypulled for the wrong arch/OS), and also note the correct import isfrom ultralytics import YOLO(capitalized), notyolo; please paste the text output ofyolo checksplus the full traceback here in this discussion, and confirmuname -m+ whether you’re on Raspberry Pi OS Bookworm 64-bit as in the Raspberry Pi YOLO26 guide; as a quick way to rule out env issues you can also try our ARM64 Docker flow from that guide:```bash t=ultralytics/ultralytics:latest-arm64 sudo docker pull $t && sudo docker run -it --ipc=host $t python -c "from ultralytics import YOLO; YOLO('yolo11n.pt')"
inuropix
Hi.. I get an error when implement botsort with reid is True and the model is ncnn(exported from yolo26n-cls.pt)
Here’s the full traceback from the error:
self.tracks = self.model.track( ^^^^^^^^^^^^^^^^^ File "/home/sbr/people_counting/lib/python3.11/site-packages/ultralytics/engine/model.py", line 579, in track return self.predict(source=source, stream=stream, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sbr/people_counting/lib/python3.11/site-packages/ultralytics/engine/model.py", line 536, in predict return self.predictor.predict_cli(source=source) if is_cli else self.predictor(source=source, stream=stream) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sbr/people_counting/lib/python3.11/site-packages/ultralytics/engine/predictor.py", line 225, in __call__ return list(self.stream_inference(source, model, *args, **kwargs)) # merge list of Results into one ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sbr/people_counting/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 40, in generator_context response = gen.send(None) ^^^^^^^^^^^^^^ File "/home/sbr/people_counting/lib/python3.11/site-packages/ultralytics/engine/predictor.py", line 338, in stream_inference self.run_callbacks("on_predict_postprocess_end") File "/home/sbr/people_counting/lib/python3.11/site-packages/ultralytics/engine/predictor.py", line 509, in run_callbacks callback(self) File "/home/sbr/people_counting/lib/python3.11/site-packages/ultralytics/trackers/track.py", line 93, in on_predict_postprocess_end tracks = tracker.update(det, result.orig_img, getattr(result, "feats", None)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sbr/people_counting/lib/python3.11/site-packages/ultralytics/trackers/byte_tracker.py", line 361, in update dists = self.get_dists(unconfirmed, detections) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sbr/people_counting/lib/python3.11/site-packages/ultralytics/trackers/bot_sort.py", line 220, in get_dists emb_dists = matching.embedding_distance(tracks, detections) / 2.0 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sbr/people_counting/lib/python3.11/site-packages/ultralytics/trackers/utils/matching.py", line 128, in embedding_distance cost_matrix = np.maximum(0.0, cdist(track_features, det_features, metric)) # Normalized features ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sbr/people_counting/lib/python3.11/site-packages/scipy/spatial/distance.py", line 2903, in cdist raise ValueError('XA must be a 2-dimensional array.') ValueError: XA must be a 2-dimensional array.Any idea?
Glenn JocherUltralyticsThat traceback usually means BoT-SORT didn’t get valid (2D) ReID embeddings; also note that
.track()should run with a Detect/Seg/Pose model, whileyolo26n-clsis only meant to be the ReID feature extractor configured insidebotsort.yaml(viawith_reid/model). (docs.ultralytics.com)yolo track model=yolo26n.pt source=path/to/video.mp4 tracker="botsort.yaml"# in a copy of botsort.yaml with_reid: True model: yolo26n-cls.pt # first confirm this works before swapping to an exported backendIf you just need stable tracking on Raspberry Pi, try
tracker="bytetrack.yaml"(no ReID); if you still hit this, please paste yourbotsort.yamland the output ofyolo checksso we can reproduce from the same environment. (docs.ultralytics.com)
hananabuzainab
I can't install ultralytics on rasspbery pi 5...with python 3.11 version,why??
I used: pip install ultralytics
How can i fix this problem ??
Glenn JocherUltralyticsCan you paste the full
pip install ultralyticserror text (as text, not a screenshot) and the output ofpython3 -Vhere so we can pinpoint what’s failing? On Raspberry Pi 5 this is most often a Python/pip mismatch or non-Bookworm/32-bit setup—please also confirm you’re on Raspberry Pi OS Bookworm 64-bit as in the Raspberry Pi with Ultralytics YOLO26 guide.python3 -V python3 -m pip install -U pip setuptools wheel python3 -m venv .venv source .venv/bin/activate python -m pip install -U pip python -m pip install ultralytics
avasanjesh
Hi,
I want to use python version of raspberry pi 32 bit OS. can you please tell me if i can export yolo detection model in 32 bit raspberry pi?
Edward-YS
Hello,I'm wondering if there is Benchmarking Results of Two Different Models (YOLO8n, YOLO8s) Across Ten Formats: PyTorch, TF, ONNX, OpenVINO, TF SavedModel, TF GraphDef, TF Lite, PaddlePaddle, MNN, NCNN.
zyt2011
Installing a single Hailo-5 is sufficient.
发件人: Beautifulboy111 @.> 发送时间: 2025年4月22日 14:24 收件人: ultralytics/ultralytics @.> 抄送: zyt2011 @.>; Mention @.> 主题: Re: [ultralytics/ultralytics] zh/guides/raspberry-pi/ (Discussion #19489)
Why does my Raspberry Pi 5 have a high inference latency of 150ms when using NCNN for video recognition, even after overclocking? How can I reduce the inference time?
― Reply to this email directly, view it on GitHubhttps://github.com/orgs/ultralytics/discussions/19489#discussioncomment-12906311, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BJ7DFR53TAD7QVJNO3TTXJL22XOAJAVCNFSM6AAAAABYEEJCHCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTEOJQGYZTCMI. You are receiving this because you were mentioned.Message ID: @.***>
Glenn JocherUltralytics(تم التعديل)@Beautifulboy111 150ms inference latency with NCNN on Raspberry Pi 5 is higher than expected. Here are some steps to reduce it:
-
Use a smaller YOLO26 model - our benchmarks show YOLO26n is significantly faster than YOLO26s with NCNN on Pi 5 (67ms vs 173ms)
-
Reduce input resolution - try 320x320 instead of 640x640, which can cut inference time by up to 70%
-
Optimize memory allocation by running without GUI (Raspberry Pi OS Lite)
-
Ensure you're using proper cooling for sustained performance when overclocked
-
Consider processing at lower FPS if your application allows it
Regarding @zyt2011's suggestion, while accelerators like Hailo can boost performance, they're a separate investment. I'd recommend optimizing your current setup first using the techniques in our Raspberry Pi guide.
What's your specific use case? This would help us provide more targeted optimization advice.
-
Beautifulboy111
Why does my Raspberry Pi 5 have a high inference latency of 150ms when using NCNN for video recognition, even after overclocking? How can I reduce the inference time?