Google Tensorflow on Raspberry Pi

Introduction: 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))

1 Person Made This Project!

Recommendations

  • Puzzles Speed Challenge

    Puzzles Speed Challenge
  • "Can't Touch This" Family Contest

    "Can't Touch This" Family Contest
  • CNC Contest 2020

    CNC Contest 2020

16 Discussions

0
gginping
gginping

2 years ago

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

1
AlB1
AlB1

2 years 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
Stephen LEE
Stephen LEE

Tip 2 years ago

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

1
AmanK113
AmanK113

2 years 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
Siddhufunde
Siddhufunde

2 years 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.

0
RafalF2
RafalF2

Reply 2 years 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
임성국
임성국

Reply 2 years 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
DungL21
DungL21

2 years 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.

0
meMitulGoswami
meMitulGoswami

2 years ago

thank u so much for this!!

very useful information!!

0
Stephen LEE
Stephen LEE

Reply 2 years ago

You are welcome! If you struggle it, keep asking here.

0
KevinD27
KevinD27

2 years ago

Great tutorial ! Thank you !

0
Stephen LEE
Stephen LEE

Reply 2 years ago

You are welcome!

0
PaulAtreides7201
PaulAtreides7201

2 years ago

Great tutorial, just what I needed, thanks!

0
Stephen LEE
Stephen LEE

Reply 2 years ago

You are welcome. Enjoy with TensorFlow.

0
ShubamG2
ShubamG2

3 years ago

thank you so much

0
Stephen LEE
Stephen LEE

Reply 3 years ago

You are welcome!