树莓派安装TensorFlow教程
我的环境
-
Raspberry4 / 2GB内存
-
Python 3.7.3
-
pip3 19.3.1
安装TensorFlow版本
tensorflow-1.14.0-cp37-none-linux_armv7l.whl
安装步骤
pip3换源
本来的源网站国内访问速度较慢
临时换源方式
pip install {packName} -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host = pypi.tuna.tsinghua.edu.cn
永久换源方式
- 在家目录创建pip配置文件
// 创建目录和配置文件
mkdir ~/.pip
vi .pip/pip.conf
//以下为 pip.conf 文件内容
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn
- 国内其他源
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
安装TensorFlow
- 安装命令,此命令执行完成后即可使用
#安装TensorFlow命令
sudo pip3 install tensorflow
#指定安装版本
sudo pip3 install tensorflow=={version}
#此过程中会自动安装一系列依赖包,耐心等待即可
- 虽然更换过源,不过 TensorFlow 1.14 版本,这几个源并没有收录。而且使用上面这个命令下载过于缓慢。我下载过后保存了起来,放出链接:链接: https://pan.baidu.com/s/1sPhgmghjUYh-fD9qpF5TVQ 提取码: u9ze
云盘内容 | 大小 | 说明 |
---|---|---|
tensorflow-1.14.0-cp37-none-linux_armv7l.whl | 75.9M | TensorFlow |
pyasn1-0.4.8-py2.py3-none-any.whl | 75kb | 依赖 |
grpcio-1.26.0-cp37-cp37m-linux_armv7l.whl | 16,4M | 依赖 |
- 云盘内容使用方法:先安装依赖后安装TensorFlow
- 依赖安装方法:sudo pip3 install {名称}
安装验证
#打开 python3
$ python3
#引入tensorflow包
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print sess.run(hello)
#输出的内容
Hello, TensorFlow!
如果输出以上内容说明安装完毕!
制作时间仓促,如果有未完善的地方,请评论留言!