当前位置:   article > 正文

树莓派4B安装 tensorflow 2.3.0版本以及对应Keras_tensorflow2.3.0对应keras

tensorflow2.3.0对应keras

1、在联网的树莓派界面,打开浏览器输入下面,下载tensorflow2.3.0

https://github.com/lhelontra/tensorflow-on-arm/releases/download/v2.3.0/tensorflow-2.3.0-cp37-none-linux_armv7l.whl

2、在存放whl的文件夹下按F4(一般是放在Downloads下),然后在打开的命令终端输入:

pip install tensorflow-2.3.0-cp37-none-linux_armv7l.whl
  • 1

没在所下载文件位置打开文件

Defaulting to user installation because normal site-packages is not
writeable WARNING: Requirement
‘tensorflow-2.3.0-cp37-none-linux_armv7l.whl’ looks like a filename,
but the file does not exist 这个是没有在在存放whl的文件夹下按F4(一般是放在Downloads下)

若正常

输入python3

import tensorflow as tf 查看,若没报错则安装成功

3、在终端遇到了 请更新python的错误,我直接卸载了树莓派4B自带的python2.7版本

提示:pi@raspberrypi:~ $ pip install tensorflow-2.3.0-cp37-none-linux_armv7l.whl
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality. 好像是因为python2的影响

转: 树莓派删除Python2.7 默认Python3.7 - 简书

4、要求更新pip的错误,ModuleNotFoundError: No module named ‘pip._internal.cli.main‘报错,解决方法

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
ERROR: tensorflow-2.3.0-cp37-none-linux_armv7l.whl is not a supported wheel on this platform.
WARNING: You are using pip version 20.2.4; however, version 20.3.4 is available.
You should consider upgrading via the ‘/usr/bin/python -m pip install --upgrade pip’ command.这个要求更新pip

ModuleNotFoundError: No module named ‘pip._internal.cli.main‘报错,解决方法_tacity的博客-CSDN博客

5、安装失败 ,因为下载速度较慢,出现哈希值不匹配

ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.

2022/4/4 解决哈希值不匹配,将树莓派中的源,更换为国内镜像

树莓派更改软件源 - Zbuter - 博客园

一键换取清华源:

sudo sed -i 's#://mirrordirector.raspbian.org#s://mirrors.tuna.tsinghua.edu.cn/raspbian#g' /etc/apt/sources.list sudo sed -i 's#://archive.raspberrypi.org/debian#s://mirrors.tuna.tsinghua.edu.cn/raspberrypi#g' /etc/apt/sources.list.d/raspi.list
  • 1

6、Keras安装

keras需要tensorflow作为后台。
先安装一些依赖包。

sudo apt-get install libhdf5-serial-dev
sudo pip install h5py
sudo apt-get install python-scipy
  • 1
  • 2
  • 3

最后运行sudo pip install keras,安装keras:

sudo pip install keras
  • 1

7、numpy导致的报错

报错如下,代码运行时:

ValueError: numpy.ndarray size changed, may indicate binary
incompatibility. Expected 88 from C header, got 80 from PyObject

核心原因是 numpy 版本与当前一些库不匹配
通常是因为安装的 numpy 版本过低,把 numpy 更新到最新版本即可

pip install --upgrade numpy
  • 1

如果出现:

CoreML: export failure: Unsupported numpy type: float32

此时原因是 numpy 版本当前冲突【切换正确版本即可】:

pip install numpy==1.19.5
  • 1
本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号