Tested on:Raspberry Pi 2; Python 2.7; Ubuntu Linux
Prerequisites:Installation of Ubuntu on a Raspberry Pi
Hardware:Raspberry Pi 2

Deepdreaming on a Raspberry Pi 2

Check out the new tutorial which greatly simplifies the installation process: DeepDream on the RPi3 and Raspbian Jessie!

Hooray, DeepDream runs on a Raspberry Pi 2! Please see the DeepDream on Ubuntu Linux installation tutorial for references, thanks and more comments on the installation or check out this gallery with deepdream images. This installation was tested on a Raspberry Pi 2; older models are probably too slow for running DeepDream, sadly. The complete installation will take around half a day; alternatively, the psychedelic surveilance camera PsyCam, which is based on DeepDream, could be installed from an Disk Image.

Update Ubuntu
First, the Ubuntu packages have to be refreshed. Do this with

Basic dependency installation
These are the basic dependencies required for installing DeepDream on a Raspberry Pi:

Caffe installation
Caffe is the neural network engine used for DeepDream. Install it with

In the now-open file, change the line


and replace


Then, open db_lmdb.cpp with sudo nano ./src/caffe/util/db_lmdb.cpp and change


Now, everything is ready for installing caffe. Execute in the terminal

In the now open .bashrc, add at the end of the file

and reload .bashrc with

Protobuf installation
Protobuf is a framework for structured data and necessary for DeepDream. Install it with

In the now-open .bashrc, add at the end of the file

Then, type in the terminal

DeepDream installation
For installing DeepDream, enter

DeepDream usage
Running the DeepDream notebook was not tested, since loading the graphical Desktop environment takes too much RAM for the already exhausted Raspberry Pi. There is, however, the script deepdreaming.py in this repository, which lets the Raspberry Pi deepdream from the ubuntu terminal.
Execute the script with

to let the Raspi dream. To get some help, enter

Copy the images onto a host computer with scp for watching them.
The script was tested for a maximum input image width of 500px that did not crash the Raspberry Pi; i’d love to hear back if other image sizes work, too. The script is under development right now: another blog post on its usage will follow soon…

The complete script (beta)
Click on Full Script to show all of the code.

Dreams of a Raspberry Pi I

Dreams of a Raspberry Pi I

Dreams of a Raspberry Pi II

Dreams of a Raspberry Pi II

Dreams of a Raspberry Pi III

Dreams of a Raspberry Pi III

File transfer with SCP: http://www.knight-of-pi.org/scp-copy-linux-raspberry/
Interceptionism: Going deeper into Neural Networks: http://googleresearch.blogspot.ch/2015/06/inceptionism-going-deeper-into-neural.html
Installating DeepDream on Ubuntu: http://www.knight-of-pi.org/installing-the-google-deepdream-software/
DeepDream Image Gallery: http://s478.photobucket.com/user/wirsing/library/DeepDream
DeepDream psycedelic CCTV: http://www.knight-of-pi.org/psycam-a-raspberry-pi-deepdream-surveilance-camera/
DeepDream on the RPi3 and Raspbian Jessie: http://www.knight-of-pi.org/deepdream-on-the-raspberry-pi-3-with-raspbian-jessie/
Installing DeepDream on Ubuntu: http://www.knight-of-pi.org/installing-the-google-deepdream-software/

Knight of Pi

Johannes Bergs aka Knight of Pi. Diploma in Bioinformatics, some Webdesign and Python coding then. Living in the beautiful city of Vienna.


  1. I was hoping that installing protobuf from this tutorial would fix it, but is still get an error like this, when launching a C++ code, that uses Caffe.

    [libprotobuf ERROR google/protobuf/descriptor_database.cc:57] File already exists in database: caffe.proto
    [libprotobuf FATAL google/protobuf/descriptor.cc:1018] CHECK failed: generated_database_->Add(encoded_file_descriptor, size):
    terminate called after throwing an instance of ‘google::protobuf::FatalException’
    what(): CHECK failed: generated_database_->Add(encoded_file_descriptor, size):

  2. Thanx for tutorial. on Rpi3 caffe stops compiling
    src/caffe/layers/hdf5_output_layer.cpp:3:18: fatal error: hdf5.h: No such file or directory
    #include “hdf5.h”
    compilation terminated.
    Makefile:575: recipe for target ‘.build_release/src/caffe/layers/hdf5_output_layer.o’ failed
    make: *** [.build_release/src/caffe/layers/hdf5_output_layer.o] Error 1

    What cai I do?

  3. Awesome tutorial! managed to get it running with the following additions:-

    sudo apt-get install cython
    sudo apt-get install python-skimage
    set the INCLUDE_DIRS in Makefile.config to include /usr.include.hdf5/serial/
    set the LIBRARY_DIRS in Makefile.config to include /usr/lib/arm-linux-gnueabihf/hdf5/serial/


    • So, it’s been some time but i just tried the install on Jessie and with the help of you and Ralf it worked like a charm, thank you very much! I’ll make another tutorial for Jessie these days.

  4. A thousand thanks for this recipe. It also works on the the Pi 3 with Raspbian Jessie (2016-03-18).
    It was necessary to install a recent version of cython via “python setup.py install” as explained in http://docs.cython.org/src/quickstart/install.html. Further INCLUDE_DIRS in ~/deepdreeam/caffe/Makefile.config has to be replaced by “INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial” and the following symbolic links have to be set
    cd /usr/lib/arm-linux-gnueabihf
    sudo ln -s libhdf5_serial.so libhdf5.so
    sudo ln -s libhdf5_serial_hl.so libhdf5_hl.so

    Unfortunately the modifications in db_lmdb.cpp don’t apply anymore as there is no 1099511627776 anymore.


Time limit is exhausted. Please reload CAPTCHA.