在Raspberry Pi 4 Model B(Python3.9.2)安装Pytorch与scikit-image遇阻求助
解决树莓派4B(Python3.9.2)上PyTorch与scikit-image的安装问题
PyTorch安装问题修复
1. Wheel不兼容错误
ERROR: torch-1.12.0a0+git67ece03-cp39-cp39-linux_aarch64.whl is not a supported wheel on this platform.
- 先确认系统架构:执行
uname -m,树莓派4B默认可能是armv7l(32位)或aarch64(64位),你下载的wheel是针对aarch64的,如果系统是32位,必然报错。 - 对应架构选择稳定版预编译包安装:
- 32位系统(armv7l):先更新pip,再执行适配命令:
pip3 install --upgrade pip pip3 install torch==1.11.0 torchvision==0.12.0 --extra-index-url https://download.pytorch.org/whl/cpu - 64位系统(aarch64):确保系统是64位Raspberry Pi OS,直接用官方稳定版命令安装,避开非官方测试版wheel。
- 32位系统(armv7l):先更新pip,再执行适配命令:
2. Git TLS连接中断错误
- 临时关闭Git SSL验证(仅用于解决连接问题,不建议长期开启):
git config --global http.sslVerify false - 换用国内PyPI源绕开Git克隆的网络问题:
pip3 install torch torchvision -i https://pypi.tuna.tsinghua.edu.cn/simple
scikit-image安装问题修复
解决编译卡死、高温问题
树莓派CPU性能有限,源码编译scikit-image会耗尽系统资源,优先用预编译包安装:
- 方法1:系统包管理器安装(适配性最优):
sudo apt update sudo apt install python3-skimage - 方法2:PyPI预编译wheel安装,国内源加速:
pip3 install scikit-image -i https://pypi.tuna.tsinghua.edu.cn/simple - 若必须源码编译(不推荐):先扩容swap分区缓解内存压力,再执行安装:
安装时尽量关闭其他后台程序,避免系统负载过高。sudo dphys-swapfile swapoff sudo sed -i 's/CONF_SWAPSIZE=100/CONF_SWAPSIZE=2048/' /etc/dphys-swapfile sudo dphys-swapfile swapon
内容的提问来源于stack exchange,提问作者TRY_1210
相关产品推荐
相关产品推荐

