Image Recognition on the Raspberry Pi 2

raspberrypie

Photo by Shashinjutsu

I loved the original Raspberry Pi, it was a great platform to run deep neural networks on, especially with a fully-programmable GPU. I was excited when the new Pi 2 was released, because it was even more powerful for the same low price. Unfortunately I heard back from early users that the GPU code I had been using no longer worked, the device just crashed when the example program was run.

I ordered a Pi 2, and this weekend I was finally able to devote a few hours to debugging the problems. The bad news is that I wasn’t able to figure out why the GPU code is being problematic. The good news is that the CPU’s so improved on the Pi 2 that I’m able to run even faster without it, in 3.2 seconds!

I’ve checked in my changes, and you can see full directions in the README, but the summary is that by using Eigen and gcc 4.8, NEON code on the CPU is able to run the matrix calculations very fast. One of my favorite parts of joining Google has been all the open-source heroes I’ve been able to hang out with, and I’ve got to know Benoit Jacob , the founder, and Benoit Steiner, a top contributor to the Eigen project. I knew they’ve been doing amazing work improving ARM performance, so I was hopeful that the latest version would be a big step forward. I was pleased to discover that the top of tree is almost 25% faster than the last stable release in January!

Let me know how you get on if you do dive in. I’ve had a lot of fun with this, and I hope you do too!

8 responses

  1. Pingback: Jetpac’s deep learning framework on the Beaglebone Black « Pete Warden's blog

  2. Hi Pete,

    I’ve tried your install instructions numerous times for the RPI V2, with no success.

    I’m getting errors similar to this numerous times:

    src/lib/math/matrix_gemm.o:/home/pi/projects/DeepBeliefSDK/source/../eigen/Eigen/src/Core/MathFunctions.h:891: first defined here
    src/lib/graph/buffer.o: In function `bool Eigen::numext::isnan(float const&)’:

    Then substitute the ‘bool Eigen::nutext::XXXX with a number of similar kinds of functions.

    Any ideas?

    I’m installing the DeepBeliefSDK in ~/projects and eigen is also installed to ~/projects

    I’m really interested in getting this to be a complementary feature as part of a wearable machine to provide vision assistance to the blind.

    for more information see after-sight.com

    We already have a sensory substitution algorithm working well. This would be icing on the cake.

  3. Also, just another question?

    From what I gather on the raspberry pi V1, you are using highly optimized GPU functions to do the processing, but on the pi V2 you are using a computation library to do the calculations via the multicore CPU?

    If this is correct, is there any advantage to looking at the GPU on the rpi V2?

  4. On RaspberryPi V2 everything compiled without errors for me following the original instructions. Except when I run the command: ./jpcnn -i data/dog.jpg -n ../networks/jetpac.ntwk -t -m s I get the following error: Can’t open device file: /var/lib/jpcnn/char_dev . The device file exists and it is fully accessible (checked the permissions: 0 crwxr-xr-x 1 root root 100, 0 Nov 6 15:06 /var/lib/jpcnn/char_dev ). Any ideas ?

  5. Pingback: nl comments on "Deep belief image recognition on Raspberry Pi"

  6. Hi Pete, Thank’s so much for your work. Perhaps you would like to know some results:

    I’ve just tested dog.jpg in the new RPi3(B) and I achieved these values:

    eigen: 3008 ms
    piqpi: 4841 ms (I need to add -I./src/lib/pi in Makefile for TARGET=pi2)
    default: (GEMM=) 4920 ms

    I think I’m not using piqpi code.

    Otherwise, I found a solution for the /var/lib/jpcnn/char_dev problem by removing the device a manually recreating a new one, changing the major_num 100 to 249:

    sudo ls -alt /dev/vcio
    sudo rm /var/lib/jpcnn/char_dev
    sudo /bin/mknod /var/lib/jpcnn/char_dev c 249 0

    • hi Luis F Romero,could you tell me that how you finished DeepbeliefSDk to your RP3 ,i need your help. thanks!

  7. Pingback: Developing an open source optical sorter for coffee

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: