Events


More Events...

 

Installing DarkNet Yolo on a Raspberry Pi 4

 

These are the instructions for installing darknet yolo ona Raspberry pi 4 with 4G ram.

 

We will install darknet via the NNPACK package which allows darknet to operate without a GPU and make full use of the 4 cores on the Pi.

This assumes a new install of Raspbian Buster with only the desktop.


Note: Much of this material came from:

Fun of DIY  http://funofdiy.blogspot.com/2018/08/deep-learning-with-raspberry-pi-real.html

darknet-nnpack  https://github.com/zxzhaixiang/darknet-nnpack

 

Installing Opencv 4.1 on Raspberry pi  https://www.pyimagesearch.com/2018/09/26/install-opencv-4-on-your-raspberry-pi/

 

1. Install the Buster OS on the PI 4


The 4G version of the raspberry pi 4 is great, also install a heat sink on it as it's going to get hot.

A 16G cat 10 micro SD card will be fine. Use the Buster image with just the desktop on it.

 

 

2. Instal the Ninja Building tool

 

Install PeachPy and confu:


sudo pip install --upgrade git+https://github.com/Maratyszcza/PeachPy

sudo pip install --upgrade git+https://github.com/Maratyszcza/confu

 

Do this as the pi user NOT root, you need to be in the /home/pi dir.

 

git clone https://github.com/ninja-build/ninja.git

cd ninja

git checkout release

./configure.py --bootstrap

export NINJA_PATH=$PWD

cd

 


3. Install the Modified NNPACK, install dependencies, configure, and build

 

Do this as the pi user NOT root, you need to be in the /home/pi dir.

As the pi user do the following at the command prompt:

 

git clone https://github.com/shizukachan/NNPACK

cd NNPACK

confu setup

 

Then run:

 

python ./configure.py --backend auto

 

Build the NNPACK with ninja:

 

 $NINJA_PATH/ninja

 

Run the ls command and you should see the lib and include dirs.

 

 

4. Test if NNPACK is working

Do this as the pi user NOT root, you need to be in the /home/pi dir.

 

Run this command:

 

bin/convolution-inference-smoketest

 

The test should pass and you are ready for the next part. If the test fails don't panic just try it again and all should be well.

 

 

5. Now we need to make the changes stick by copying the relevant files into the system with the commands below


Note: These all need to be run as root thus the sudo's

 

sudo cp -a lib/* /usr/lib/

sudo cp include/nnpack.h /usr/include/

sudo cp deps/pthreadpool/include/pthreadpool.h /usr/include/



 

7. Install darknet-nnpack


Now we need to install darknet-nnpack. The instructions at https://github.com/zxzhaixiang/darknet-nnpack are very good. Follow them and you should be fine.

 

As the pi user run the following commands:

 

cd

git clone -b yolov3 https://github.com/zxzhaixiang/darknet-nnpack

cd darknet-nnpack

git checkout yolov3

make

 

 

 

 

git clone https://github.com/shizukachan/NNPACK
           cd NNPACK
           confu setup
           python ./configure.py --backend auto