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+.

  • Hi @Doug Park, Ah, let met see. I vaguely remember that I successfully installed TensorFlow some two weeks ago. But I forgot what version was it. You might like to confirm if my version is old. I am happy to try the new version again. raspberrypi.stackexchange.com/questions/103983/…. – tlfong01 Oct 21 '19 at 1:41
  • Hi @Doug Park, And there you are, the complete TensorFlow installation record: penzu.com/public/3970e2d0. – tlfong01 Oct 21 '19 at 1:45
  • @tifongg01 Thanks, I looked at your output. I had run across that earlier, but I wasn't experiencing a memory issue so I hadn't tried that. So I tried setting the memory higher. I still get version 1.13.1. sudo pip3.7 install --upgrade tensorflow .... elided lines.... Successfully installed tensorflow-1.13.1 – Doug Park Oct 21 '19 at 3:42
  • I don't doubt that it worked for you some time ago. It just looks like right now the newer version isn't available. I'm not particularly savvy with python, and I may be missing something obvious. If I am I would be very happy to have any oversights pointed out. Thanks for your help. I will keep trying. – Doug Park Oct 21 '19 at 3:48
  • Thank you for your verification. My apologies for misleading you that I had a successful TF2.0 installation. So it is either an incomplete installation, or another old version 1.13.1. That is disappointing. Indeed I have been following this tensorFlow thing for a couple of years, and I always found that Ubuntu is always perhaps one or two years ahead of Debain/Raspbian. So I need to wait a little bit longer. Please fell free to ask me to try other Rpi TF 2.0 installations. Cheers. – tlfong01 Oct 21 '19 at 3:50
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.

| improve this answer | |
  • But this page says Raspbian 9.0 or later are OK! tensorflow.org/install/pip – tlfong01 Oct 21 '19 at 14:29
  • @ tlfong01 Looks like if you scroll to the bottom of the page it is self contradictory in that is says there is not support for 2.0. It also say's that there is support for 1.14 which isn't accurate either. 1.14 is supported for some but not all versions of Python. Newer versions fall back to 1.13.1. piwheels.org/simple/tensorflow – Doug Park Oct 22 '19 at 2:47
  • @Doug Park, (1) You seem to leave a space between "@" and my user name, therefore I got no notification. Yes, I agree the "official" announcement is confusing. This time there is another installation using "PyPi", but the page there is disappointing. Last time when I started to install TF2, I remember they said the following good news: "Rpi4B ready", "buster ready", "can install with or without env", .. But now they no longer mention Rpi4 buster, only "raspbian 9". Last time I remember they said TF2 with or without GPU etc. Now I know there is a trap ... /to continue, ... – tlfong01 Oct 22 '19 at 8:50
  • ie, there might be other troubles if you don't use env. Last time I was misled to think that they solved all teething problems and started a new page for Rpi4B buster. Looking back, I now think that "There ain't only one cockroach in the kitchen, ... ". I gave up and would stall for at least 3 months, before coming back. PS - I think I almost made it this time, except the "h5py" incompatible data type thing, which I think is a serious bug, not easily removed. – tlfong01 Oct 22 '19 at 8:55
  • @tlfong01 Actually, the page says "The following 64-bit systems are supported", and then lists Raspbian, which is 32-bit. – Dmitry Grigoryev Oct 22 '19 at 9:46
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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.