目录
-1、注意,必须先升级到64bit!!!
0、安装远程桌面
1、更换apt源:
2、修改配置文件
3、下载pytorch安装文件
4、开始安装
5、开始使用
-1、注意,必须先升级到64bit!!!
Index of /raspios_arm64/images
0、安装远程桌面
sudo apt-get install xrdp
然后windows远程桌面即可连接树莓派。
1、更换源
更换apt源
Raspbian 源使用帮助 — USTC Mirror Help 文档
代码语言:javascript复制sudo nano /etc/apt/sources.list
代码语言:javascript复制deb https://mirrors.ustc.edu.cn/debian/ buster main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian buster main contrib non-free
deb https://mirrors.ustc.edu.cn/debian/ buster-updates main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian buster-updates main contrib non-free
deb https://mirrors.ustc.edu.cn/debian-security buster/updates main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian-security/ buster/updates main non-free contrib
代码语言:javascript复制sudo apt-get update
sudo apt-get upgrade
更换pip源
代码语言:javascript复制mkdir ~/.pip
vim ~/.pip/pip.conf
代码语言:javascript复制[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple
2、修改配置文件
编译 torch 需要花费大量的内存,在低于 2g 或以下内存的树莓派上,可以通过增加虚拟内存来防止OOM,4g 或 8g 的版本的树莓派可跳过这步。
代码语言:javascript复制sudo nano /etc/dphys-swapfil
设置 4g 的交换内存,文件内容如下:
代码语言:javascript复制# /etc/dphys-swapfile - user settings for dphys-swapfile package
# author Neil Franklin, last modification 2010.05.05
# copyright ETH Zuerich Physics Departement
# use under either modified/non-advertising BSD or GPL license
# this file is sourced with . so full normal sh syntax applies
# the default settings are added as commented out CONF_*=* lines
# where we want the swapfile to be, this is the default
#CONF_SWAPFILE=/var/swap
# set size to absolute value, leaving empty (default) then uses computed value
# you most likely don't want this, unless you have an special disk situation
CONF_SWAPSIZE=4096
保存退出,重启服务生效。
代码语言:javascript复制sudo service dphys-swapfile restart
查看一下 swap 是否已调整。
代码语言:javascript复制swapon -s
3、下载pytorch安装文件
GitHub - Qengineering/PyTorch-Raspberry-Pi-64-OS: PyTorch installation wheels for Raspberry Pi 64 OS
下载完传到树莓派。
4、开始安装
代码语言:javascript复制sudo apt-get install python3-pip libopenblas-dev libopenmpi-dev libomp-dev -y
sudo -H pip3 install --upgrade setuptools
sudo -H pip3 install Cython
sudo -H pip3 install torch-1.10.0a0 git36449ea-cp37-cp37m-linux_aarch64.whl
5、开始使用
代码语言:javascript复制python3
import torch