Machine learning, Raspberry Pi, Robotics

Machine Learning with Raspberry Pi

Although Machine learning appears as a high-tech term, we come across it every day without knowing it. For example tasks such as filtering of spam mails, automatic tagging of facebook photos are accomplished by Machine learning algorithms.   In recent years a new area of Machine learning, known as deep learning is getting lot of  attention, as a promising route for achieving artificial intelligence.

Until recently this knowledge of deep learning is confined to only big data centers. This is because,  the deep learning technology requires large amount of data sets, which only big data mining firms such as Google, Facebook, Microsoft have access to. To keep this technology in every one’s hand, a new startup  Jetpac  has given the access to their deep learning technology to everyone with a computing device (check their app). This is exciting because, many people have  mobile phones, which have so much of computing power. Just see what can be done with such kind of democratization of technology in the above video.

Now coming to the Raspberry Pi, it has roughly 20 GFLOPS (almost same as the Parallela board offers) of computing power, thanks to its GPU. After Broadcam has released the documentation for the GPU specs, Pete Warden has done a great job by porting his Deep Belief Image recognition SDK to the Raspberry Pi. Today after seeing about this post in the Raspberry Pi Blog, I have tried to follow his instructions and successfully run the first example on my Pi.

Instructions to install Deep Belief on Raspberry Pi

This algorithm requires at least 128 MB of RAM dedicated to GPU. To allocate that, we need to edit /boot/config.txt. We do it by using the following command

sudo nano /boot/config.txt

Then add the following line at the end of  /boot/config.txt


save and exit the editor. Now we have to reboot the Raspberry Pi to get a ‘clean’ area of memory.

sudo reboot

Install git by using the following command

sudo apt-get install git

We are now ready to install the Deep belief. Just follow the below instructions

git clone
cd DeepBeliefSDK/RaspberryPiLibrary
sudo ./

That’s it. You have installed one of the best Machine learning algorithm on Pi. Now to test whether everything is working or not, hit the following commands.

cd ../examples/SimpleLinux/
sudo ./deepbelief 

If everything goes well, you should see the following output

0.016994    wool
0.016418    cardigan
0.010924    kimono
0.010713    miniskirt
0.014307    crayfish
0.015663    brassiere
0.014216    harp
0.017052    sandal
0.024082    holster
0.013580    velvet
0.057286    bonnet
0.018848    stole
0.028298    maillot
0.010915    gown
0.073035    wig
0.012413    hand blower
0.031052    stage
0.027875    umbrella
0.012592    sarong

Pete Warden has explained how to implement this algorithm for various applications on Gitgub. I would like to use this for my Robotic project, so that my robot can recognize the objects around it, just like the Romo in the above video. I am planning to do this with Open CV.


If you don’t allocate sufficient RAM for GPU, you may get the following error.

Unable to allocate 7778899 bytes of GPU memory
mmap error -1



6 thoughts on “Machine Learning with Raspberry Pi

  1. Pingback: Raspberry Pi Spotter | scientistnobee

  2. Pingback: Teaching Raspberry Pi to teach itself - West Florida Components

    • Hi Aaleskh, You can use now use pi3, with its built in wifi and using rpi camera. Also you can make the code better. Also new pi has better GPU and faster processor. You can use the same hardware to make submarine and detecting different things under water.

  3. Msalow says:

    when I entered “sudo ./deepbelief” as the last command it gave me the error, “Can’t open device file: /var/lib/jpcnn/char_dev”. Do you know what i could do to fix it? Thank you

Leave a Reply

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

You are commenting using your 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