Install TensorFlow 1.15.0 on Raspberry Pi

Hello. I wanted to install TensorFlow version 1.15.0 or later on my Raspberry Pi. It didn't work with pip, and I couldn't find anything in Japanese, so I'll put together a memorandum.

environment

The environment of Raspberry Pi is as follows.

$ uname -a
#Linux raspberrypi 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l GNU/Linux
$ lsb_release -a                 
#No LSB modules are available.
#Distributor ID: Raspbian
#Description:    Raspbian GNU/Linux 9.11 (stretch)
#Release:        9.11
#Codename:       stretch

The Python version is below.

$ python3 --version
#Python 3.5.3
$ python3 -m pip --version
#pip 20.0.2 from /home/pi/.local/lib/python3.5/site-packages/pip (python 3.5)

Install TensorFlow

Installation with pip

I tried to install with pip as usual.

$ pip3 install tensorflow==xxx
#Could not find a version that satisfies the requirement tensorflow==xxx (from versions: 0.11.0,  1.8.0, 1.9.0, 1.10.0, 1.11.0, 1.12.0, 1.13.1, 1.14.0)
#No matching distribution found for tensorflow==xxx

However, it seems that you can only install up to 1.14.0 from Raspberry Pi. Therefore, I decided to install it by another method.

Build from source

Build from the information on the official page

According to TensorFlow official page, it seems that it can be installed by building from the source of Raspberry Pi. We will build using docker. Since it takes time to build on Raspberry Pi, it is better to cross-compile, so I will build on mac. In conclusion, I couldn't build this way.

mac


$ docker --version
#Docker version 19.03.5, build 633a0ea

Clone from github. I want to install 1.15.0 this time, so check out the branch.

mac


$ git clone https://github.com/tensorflow/tensorflow.git
$ cd tensorflow
$ git checkout r1.15

Cross-compile according to the official page.

mac


$ CI_DOCKER_EXTRA_PARAMS="-e CI_BUILD_PYTHON=python3 -e CROSSTOOL_PYTHON_INCLUDE_PATH=/usr/include/python3.4" \
        tensorflow/tools/ci_build/ci_build.sh PI-PYTHON3 \
        tensorflow/tools/ci_build/pi/build_raspberry_pi.sh

When the build is complete (about 30 minutes), a .whl package file will be created in the output artifact directory of the host's source tree.

However, the build did not complete with the following error.

#addgroup: Please enter a username matching the regular expression configured
#via the NAME_REGEX[_SYSTEM] configuration variable.  Use the `--force-badname'
#option to relax this check or reconfigure NAME_REGEX.

When I looked it up, I found isuue that it couldn't be built using the official procedure.

Why can't I stay official? .. .. It feels like There was a person in the issue who gave a natively built file, so this time I will use it.

Install from build file

It is listed in Tensorflow-bin, so install it referring to the README.

Since the environment of Raspberry Pi is Raspbian 9.11 (stretch), use tensorflow-1.15.0-cp35-cp35m-linux_armv7l.whl.

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install -y libhdf5-dev libc-ares-dev libeigen3-dev gcc gfortran python-dev \
         libatlas3-base libatlas-base-dev libopenblas-dev libopenblas-base libblas-dev \
         liblapack-dev cython openmpi-bin libopenmpi-dev libatlas-base-dev python3-dev 
#I pulled it out because libgfortran5 could not be installed
$ sudo pip3 install keras_applications==1.0.8 --no-deps
$ sudo pip3 install keras_preprocessing==1.1.0 --no-deps
$ sudo pip3 install h5py==2.9.0
$ sudo pip3 install pybind11
$ pip3 install -U --user six wheel mock
$ sudo pip3 uninstall tensorflow
$ wget https://github.com/PINTO0309/Tensorflow-bin/raw/master/tensorflow-1.15.0-cp35-cp35m-linux_armv7l.whl
$ sudo pip3 install tensorflow-1.15.0-cp35-cp35m-linux_armv7l.whl

The last install command failed several times with TypeError: unsupported operand type (s) for-=:'Retry' and'int', but without a doubt sudo pip3 install tensorflow-1.15.0 When I typed -cp35-cp35m-linux_armv7l.whl, the installation was successful in about 5 times. .. ..

$ python3
>>> import tensorflow as tf
>>> tf.__version__
1.15.0
>>> exit()

You have successfully installed 1.15.0! Today is up to here.

Recommended Posts

Install TensorFlow 1.15.0 on Raspberry Pi
Install OpenCV4 on Raspberry Pi 3
raspberry pi 4 centos7 install on docker
Install OpenMedia Vault 5 on Raspberry Pi 4
Install Tensorflow on Mac
Install TensorFlow on Ubuntu
Install 64-bit OS (bate) on Raspberry Pi
Install docker-compose on 64-bit Raspberry Pi OS
Cython on Raspberry Pi
How to install NumPy on Raspberry Pi
Install Raspberry Pi OS (Raspbian)
Use NeoPixel on Raspberry Pi
Install pyenv on Raspberry Pi and version control Python
Install CUDA10.1 + cuDNN7.6.5 + tensorflow-2.3.0 on Ubuntu 18.04
MQTT on Raspberry Pi and Mac
Try using ArUco on Raspberry Pi
OpenCV installation procedure on Raspberry Pi
How to install TensorFlow on CentOS 7
Power on / off Raspberry pi on Arduino
Detect switch status on Raspberry Pi 3
L Chika on Raspberry Pi C #
Build wxPython on Ubuntu 20.04 on raspberry pi 4
"Honwaka Notification Lamp" on Raspberry Pi Part 2
Detect "brightness" using python on Raspberry Pi 3!
USB boot on Raspberry Pi 4 Model B
"Honwaka Notification Lamp" on Raspberry Pi Part 1
Build a Tensorflow environment with Raspberry Pi [2020]
Enable UART + serial communication on Raspberry Pi
Adafruit Python BluefruitLE works on Raspberry Pi.
Accelerate Deep Learning on Raspberry Pi 4 CPU
Programming normally with Node-RED programming on Raspberry Pi 3
Raspberry Pi backup
Use the Grove sensor on the Raspberry Pi
Install tensorflow. (Only!)
Run servomotor on Raspberry Pi 3 using python
"Honwaka Notification Lamp" on Raspberry Pi Part 3
Working with sensors on Mathematica on Raspberry Pi
Build OpenCV-Python environment on Raspberry Pi B +
Detect temperature using python on Raspberry Pi 3!
Mount Windows shared folder on Raspberry Pi
Matrix multiplication on Raspberry Pi GPU (Part 2)
I installed OpenCV-Python on my Raspberry Pi
Working with GPS on Raspberry Pi 3 Python
Why detectMultiScale () is slow on Raspberry Pi B +
Detect slide switches using python on Raspberry Pi 3!
Build a Django environment on Raspberry Pi (MySQL)
Try using a QR code on a Raspberry Pi
Detect magnet switches using python on Raspberry Pi 3!
Power on / off your PC with raspberry pi
Use Grove-Temperature & Humidity Sensor (DHT11) on Raspberry Pi
Beginning cross-compilation for Raspberry Pi Zero on Ubuntu
Sound the buzzer using python on Raspberry Pi 3!
Play with your Ubuntu desktop on your Raspberry Pi 4
Display CPU temperature every 5 seconds on Raspberry Pi 4
Introduced Ceph on Kubernetes on Raspberry Pi 4B (ARM64)
Install the machine learning library TensorFlow on fedora23
Connect to MySQL with Python on Raspberry Pi
Build a Python development environment on Raspberry Pi
Build an Arch Linux environment on Raspberry Pi
Install mecab on Marvericks
Install python on WSL