This is the easiest way to get TensorFlow onto your Raspberry Pi 3. Note that currently, the pre-built binary is targeted for Raspberry Pi 3 running Raspbian 8.0 ("Jessie"), so this may or may not work for you.
First, install the dependencies for TensorFlow:
# 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/raw/master/bin/tensorflow-0.9.0-cp27-none-linux_armv7l.whl
$ sudo pip install tensorflow-0.9.0-cp27-none-linux_armv7l.whl
# For Python 3.3+
$ wget https://github.com/samjabrahams/tensorflow-on-raspberry-pi/raw/master/bin/tensorflow-0.9.0-py3-none-any.whl
$ sudo pip install tensorflow-0.9.0-py3-none-any.whl
Troubleshooting
This section will attempt to maintain a list of remedies for problems that may occur while installing from
pip"tensorflow-0.9-cp27-none-linux_armv7l.whl is not a supported wheel on this platform."
This wheel was built with Python 2.7, and can't be installed with a version of
pip that uses Python 3. If you get the above message, try running the following command instead:$ sudo pip2 install tensorflow-0.9-cp27-none-linux_armv7l.whl
Vice-versa for trying to install the Python 3 wheel. If you get the error "tensorflow-0.9-py3-none-any.whl is not a supported wheel on this platform.", try this command:
$ sudo pip3 install tensorflow-0.9-py3-none-any.whl
Building from Source
If you aren't able to make the wheel file from the previous section work, you may need to build from source. Additionally, if you want to use features that have not been included in an official release, such as the initial distributed runtime, you'll have to build from source. Don't worry, as we've figured out most of the quirks of getting it right. The guide will be updated as needed to be as correct as possible.
See the step-by-step guide here. Warning: it takes a while.
https://github.com/jikexueyuanwiki/tensorflow-zh/blob/master/SOURCE/get_started/os_setup.md
尝试你的第一个 TensorFlow 程序
(可选) 启用 GPU 支持
如果你使用 pip 二进制包安装了开启 GPU 支持的 TensorFlow, 你必须确保 系统里安装了正确的 CUDA sdk 和 CUDNN 版本. 请参间 CUDA 安装教程
你还需要设置
LD_LIBRARY_PATH 和 CUDA_HOME 环境变量. 可以考虑将下面的命令 添加到 ~/.bash_profile 文件中, 这样每次登陆后自动生效. 注意, 下面的命令 假定 CUDA 安装目录为 /usr/local/cuda:export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64"
export CUDA_HOME=/usr/local/cuda
运行 TensorFlow
打开一个 python 终端:
$ python
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print sess.run(hello)
Hello, TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print sess.run(a+b)
42
>>>