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