1

I have been trying to install Tensorflow 2.0 on Raspberry Pi 4 (Buster). The documentation here make it seem easy. And indeed it seems to work. However, it installs 1.13.1 (not 2.0). I have successfully installed Tensorflow 2.0 on Ubuntu 18.04 so I think I have some idea of what I'm doing. I am using Python 3.7.4 on my Pi 4.

I have also tried this using my Pi 3 B+ also running Buster. I get the same result.

I started down the rabbit trail of building it from source, but that also failed. I am not particularly interested in building it from scratch. I have not tried building from source on the Pi 3B+.

tlfong01
  • 4,847
  • 3
  • 12
  • 24
Doug Park
  • 11
  • 3

2 Answers2

1

I believe Tensoflow 2 is not supported on Raspbian:

  • The build instructions suggest you should be using 1.x branch

  • The pre-build packages for Raspbian are v1.14, packages for regular Linux are v2.0.0

Tensoflow 2 seems to be only supported on a 64-bit OS.

Dmitry Grigoryev
  • 28,277
  • 6
  • 54
  • 147
0

Hey I recently figured this out. Installing Tensorflow requires some extra steps on the Pi's ARM architecture but it wasn't that bad. Let me know if this works for you!

This is how I installed tf 2 on my Pi 4 with Python 3.7.4

Make a project directory:

cd Desktop
mkdir tf_pi
cd tf_pi

Make a virtual environment:

python3 -m pip install virtualenv
virtualenv env
source env/bin/activate

Run the commands based on https://github.com/PINTO0309/Tensorflow-bin/#usage:

sudo apt-get install -y libhdf5-dev libc-ares-dev libeigen3-dev
python3 -m pip install keras_applications==1.0.8 --no-deps
python3 -m pip install keras_preprocessing==1.1.0 --no-deps
python3 -m pip install h5py==2.9.0
sudo apt-get install -y openmpi-bin libopenmpi-dev
sudo apt-get install -y libatlas-base-dev
python3 -m pip install -U six wheel mock

Pick a tensorflow 2.0.0 release wheel file. When I tried to get a higher version of Tensorflow I ran into issues with scipy:

wget https://github.com/lhelontra/tensorflow-on-arm/releases/download/v2.0.0/tensorflow-2.0.0-cp37-none-linux_armv7l.whl
python3 -m pip uninstall tensorflow
python3 -m pip install tensorflow-2.0.0-cp37-none-linux_armv7l.whl

RESTART YOUR TERMINAL

Reactivate your virtual environment:

cd Desktop
cd tf_pi
source env/bin/activate

Test: Open a python interpreter by executing:

python3 
import tensorflow
tensor.__version__

This should have no errors and output: 2.0.0

Here's a YouTube video I made giving the step-by-step: https://youtu.be/GNRg2P8Vqqs

Sam
  • 101
  • 7