Getting Tensorflow 1.4 on RaspberryPi 3

There are two methods to install tensorflow on raspberry pi, installing form binary which is provided by ci.tensorflow.org (you can get all nighly builds for all platform) or building from source which is hard and takes lots of time and setup. Build usually fails multiple times unless you know exactly what you do.

I will explain, how I installed tensorflow 1.4 on raspberry pi3 from pre-compiled binary.

Install pip,

# For Python 2.7
sudo apt-get install python-pip python-dev

# For Python 3.4
sudo apt-get install python3-pip python3-dev

Tensorflow nightly build for pi3 in python3 is avalilable here

Choose the date of the build, copy the link for .whl file.tensorflow nightly for raspberry pi 3

Install tensorflow, for python 3.4 use pip3 and pip for python 2.7.

sudo pip3 install http://ci.tensorflow.org/view/Nightly/job/nightly-pi-python3/39/artifact/output-artifacts/tensorflow-1.4.0-cp34-none-any.whl

or download it if you need a backup and install the file

wget http://ci.tensorflow.org/view/Nightly/job/nightly-pi-python3/39/artifact/output-artifacts/tensorflow-1.4.0-cp34-none-any.whl

sudo pip3 install ./tensorflow-1.4.0-cp34-none-any.whl

Test the installation,

$ python3
>>> import tensorflow as tf

If it is installed correctly, no errors will be shown. If there are errors while running, try uninstalling and install another nighty build binary. The tensorflow speech detection can be now run on raspberry pi after copying the files to the pi. Use scp for copying over ssh.

scp pi@192.168.1.xxx:my_frozen_graph.py /tmp/my_frozen_graph.py
scp pi@192.168.1.xxx:conv_labels.txt /tmp/speech_commands_train/conv_labels.txt
scp pi@192.168.1.xxx:a5d485dc_nohash_0.wav /tmp/speech_dataset/left/a5d485dc_nohash_0.wav

Make sure to clone the tensorflow tree from github to raspberry pi before running the label_wav.py

git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow/examples/speech_commands

python tensorflow/examples/speech_commands/label_wav.py \
--graph=./my_frozen_graph.pb \
--labels=./conv_labels.txt \
--wav=./a5d485dc_nohash_0.wav

running tensorflow speech detection on raspberry pi 3