How to install TensorFlow on Raspberry Pi 2

2019-04-11 04:12发布

I'm trying to install TensorFlow on a Raspberry Pi 2 with Raspian Lite OS installed on and a 8 Gb SD card. I'm using Python version 2.7.9 and I'm trying to install TensorFlow for it. I previously searched and tried to solve the problem by me but couldn't do it. Already followed these guides:

  1. TensorFlow Official Guide
  2. IotMakerBlog guide
  3. Sam J Abrahams guide on GitHub

I have also read a lot of solutions proposed in some other Stack Overflow questions, but the problem is always the same:

 tensorflow-1.1.0-cp27-none-linux_armv7l.whl is not a supported wheel on this platform.

This happens everytime I try to download the .whl and use pip to install it. Moreover, if I try to use pip directly, the error I get is the following:

# pip install tensorflow
Collecting tensorflow
  Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow

I also tried with pip2 as suggested in some guides and I also tried to install the Python 3 version. The result is the same as here.

Could anyone help me? Many thanks.

4条回答
The star\"
2楼-- · 2019-04-11 04:39

You can follow this:

First, install the dependencies for TensorFlow:

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.1.0/tensorflow-1.1.0-cp27-none-linux_armv7l.whl
sudo pip install tensorflow-1.1.0-cp27-none-linux_armv7l.whl

# For Python 3.4
wget https://github.com/samjabrahams/tensorflow-on-raspberry-pi/releases/download/v1.1.0/tensorflow-1.1.0-cp34-cp34m-linux_armv7l.whl
sudo pip3 install tensorflow-1.1.0-cp34-cp34m-linux_armv7l.whl

Finally, 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

See more details from tensorflow-on-raspberry-pi.

查看更多
我只想做你的唯一
3楼-- · 2019-04-11 04:42

At the end I found that the problem was the processor. Indeed, with Raspbian it is considered to be ARMv6 but it is ARMv7. So, changing OS to Ubuntu MATE did the trick. Now I have installed TensorFlow on my Pi.

查看更多
可以哭但决不认输i
4楼-- · 2019-04-11 04:45

@all, I noticed that you were trying to have tensorflow running on Raspberry Pi 2. If you are willing to try tensorflow lite on Raspberry Pi 3 as well, my "pull-request" may be useful. My contribution is at https://github.com/tensorflow/tensorflow/pull/24194.

Following my steps, 2 apps to get your own development started, label_image and camera, can run on Raspberry Pi 3.

Best,

--Jim

查看更多
戒情不戒烟
5楼-- · 2019-04-11 04:45

Miniconda (Anaconda) can install python 3.4 with a version of pip that can upgrade to the latest pip which can install tensorflow-1.11.0-cp34 as well as keras wheels for the Arm processor:

wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-armv7l.sh
bash Miniconda3-latest-Linux-armv7l.sh
pip install --upgrade pip
pip install tensorflow keras
查看更多
登录 后发表回答