Google Tensorflow on Raspberry Pi

About: I am a keen IoT inventor as a hobbyist in Sydney and very passionate about IoT and Algorithms such as MACHINE LEARNING, COMPUTATIONAL STATISTICS and so on. Also, I have spent almost every day of the past 15 ...

About TensorFlow

TensorFlow™ is an open source software library for numerical computation using data flow graphs. Nodes in the graph represent mathematical operations, while the graph edges represent the multidimensional data arrays (tensors) communicated between them.

Step 1: Installation

This is an easy way to install TensorFlow on your Raspberry Pi. Note that currently, the pre-built binary is targeted for Raspberry Pi 3 running Raspbian 8.0 ("Jessie"), so this may or may not work for you. The specific OS release is the following:

sudo apt-get update

For Python 2.7

sudo apt-get install python-pip python-dev

For Python 3.3+

sudo apt-get install python3-pip python3-dev

Next, download the wheel file from this repository and install it:

For Python 2.7

wget https://github.com/samjabrahams/tensorflow-on-raspberry-pi/releases/download/v1.0.1/tensorflow-1.0.1-cp27-none-linux_armv7l.whl

sudo pip install tensorflow-1.0.1-cp27-none-linux_armv7l.whl

For Python 3.4

wget https://github.com/samjabrahams/tensorflow-on-raspberry-pi/releases/download/v1.0.1/tensorflow-1.0.1-cp34-cp34m-linux_armv7l.whl

sudo pip3 install tensorflow-1.0.1-cp34-cp34m-linux_armv7l.whl

We need to reinstall the mock library to keep it from throwing an error when we import TensorFlow:

For Python 2.7

sudo pip uninstall mock
sudo pip install mock

For Python 3.3+

sudo pip3 uninstall mock
sudo pip3 install mock

Step 2: Veryfying

Finally, we are going to test a simple program.

import tensorflow as tf

hello = tf.constant("Hello, TensorFlow!")

sess = tf.Session()

print(sess.run(hello))

Share

Recommendations

  • Optics Contest

    Optics Contest
  • Plastics Contest

    Plastics Contest
  • Make it Glow Contest 2018

    Make it Glow Contest 2018

16 Discussions

0
None
gginping

4 months ago

Great tutorial guy........Thanks lot ....I'm worked done with Raspberry pi Noobs OS it's Working......Awesome work dude Thank You..........!!!!!!!!!!!

0
None
AlB1

8 months ago on Step 2

The Android Things platform is also another alternative to get TensorFlow up and running on the Raspberry Pi. For our test project, we used the TensorFlow Lite version to create the NeuralCandy app that combines image classifier and sugar highs. It uses TensorFlow to locally classify the captured image against the pre-trained ImageNet model, as shown here:

0
None
Stephen LEE

Tip 9 months ago

python3 -c 'import tensorflow as tf; print(tf.__version__)'

0
None
AmanK113

10 months ago

I followed the above tutorial and didn't get any error while installing tensorflow. But

when in step2- Verifying , when i do

import tensorflow as tf it shows error.

>>> import tensorflow

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

ImportError: No module named 'tensorflow'

Help me....

0
None
Siddhufunde

12 months ago

got this error when installing tensorflow

"tensorflow-1.0.1-cp34-cp34m-linux_armv7l.whl is not a supported wheel on this platform."

please help.

2 replies
0
None
RafalF2Siddhufunde

Reply 12 months ago

try this whl:

tensorflow-1.1.0-cp34-cp34m-linux_armv7l.whl

I had the same issue when installing tensorflow on raspberry 2 and I did not succeed. Then I tried with the raspberry 3 and - success - the issue disapeared

0
None
임성국RafalF2

Reply 11 months ago

$sudo pip3 install tensorflow-1.0.1-cp34-cp34m-linux_armv7l.whl

>>

$pip3 install tensorflow-1.0.1-cp34-cp34m-linux_armv7l.whl

I removed the 'sudo', and the command line works.

0
None
DungL21

11 months ago

many thanks for the instructions. I have installed successfully Tensorflow on my Raspberry Pi 3 running Raspbian. I will start to write code for text classification.