Hey all,
I’m pretty new CV in general, and just started playing with YOLOv11n last week on a Raspberry Pi 5 (4GB RAM). So far, I’ve been really impressed with how quickly inference runs on this little machine, but I’m having some trouble with the Pi crashing when I try and run an exported NCNN model. Ultralytics has a great quick-start doc for working on Pi, and I was able to get the ARM Docker container pulled and running inference without a hitch. I was also able to install Ultralytics (v8.3.202) outside of the container in a Python venv, again without issue.
I followed the instructions to export in NCNN format inside the container, and was even more blown away by 70ms inference on 640p frames. This was easily 3x faster than running the standard PyTorch model, and when running inference as a background task in a larger app, it was over 5x faster (~90ms vs ~500ms). Again, I was able to run this inside the container, and also copy the model (the full yolo11n_ncnn_model directory generated at export) outside of the container to run on the host in my venv. When running inference in the context of my larger app, I don’t think I ever saw memory usage get above 1GB, or CPU spike above 50% across the 4 cores.
Here’s where things get funky. I only played with it for an afternoon, and a few days later, I tried using it again and found that trying to load the NCNN model I’d copied out of the container would seize the Pi. Entering the container, I could still export the NCNN model (using CLI command in doc), but when trying to run the NCNN model, the Pi would always seize (fully unpingable on the network) and require a power cycle.
Things I tried…
- Logging system resource usage at the time of the 100%-reproducible crash, but didn’t capture anything that would indicate exhausting RAM or CPU
- Removing and re-pulling the image
- Perusing forums, installing older versions of Ultralytics and dependencies, both inside and outside of the container
- Installing a fresh Bookworm image to an SD card, installing in the Pi, pulling the container
Some sanity checks…
- The standard PyTorch model always worked on the Pi without a problem, inside and outside of the container; it’s just slower, as expected
- I installed the (non-ARM) container on my Ubuntu 22.04 laptop, exported NCNN, and ran – no problems here; it was isolated to the Pi
- In the exported
yolo11n_ncnn_modeldirectory,model.ncnn.binis ~10.6MB, andmodel.ncnn.paramis ~22.7kB
I came back to it again yesterday and was able to re-pull the image (there was an update in recent days). I spun up a container and lo-and-behold, I could export NCNN and run it inside and outside of the container without any problems. Ultralytics in is now at v8.3.204, which had me thinking maybe there was some bug in 202, although that still didn’t explain how it went from working to not-working.
Maybe 2 hours after NCNN was working without issue, both inside and outside the container, through Raspberry Pi power cycles, etc, I tried running NCNN and it was crashing the Pi again. Again, I went through fully removing the image and re-pulling, but no dice.
If you’ve made it this far, thanks for reading my novel! Any hunches on what could be happening here? I’m utterly perplexed, especially considering that the Docker image should be able to reproduce the same exact container again and again (disclaimer: not even close to a Docker expert). I have to imagine I’m missing something simple; hoping one of you can tell me what that is!
