组件:

  • Raspberry Pi 4B 2G

环境:

  • Linux raspbian:5.4.83
  • 指令集:aarch64
  • Miniconda:4.9.2
  • Python:3.7.10
  • Torch:1.7.1
  • torchvision:0.8.2
  • torchaudio:0.7.2

查看系统信息

uname -a

(base) pi@raspbian:~/Software$ uname -a
Linux raspbian 5.4.83-OPENFANS+20210102-v8 #1 SMP Sat Jan 2 21:52:54 CST 2021 aarch64 GNU/Linux

注:aarch64 为当前Linux支持的架构。

aarch64对应的torch版本下载:​​https://github.com/KumaTea/pytorch-aarch64/tree/v1.9.0​

安装 Torch

pip install ;torch==1.7.1 ;torchvision==0.8.2 ;torchaudio==0.7.2 -f https://torch.maku.ml/whl/stable.html

(base) pi@raspbian:~/Software$ pip install torch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 -f https://torch.maku.ml/whl/stable.html
Looking in links: https://torch.maku.ml/whl/stable.html
Collecting torch==1.7.1
Downloading https://github.com/KumaTea/pytorch-aarch64/releases/download/v1.7.1/torch-1.7.1-cp37-cp37m-linux_aarch64.whl (37.3 MB)
|████████████████████████████████| 37.3 MB 72 kB/s
Collecting torchvision==0.8.2
Downloading https://github.com/KumaTea/pytorch-aarch64/releases/download/v1.7.1/torchvision-0.8.2-cp37-cp37m-linux_aarch64.whl (13.1 MB)
|████████████████████████████████| 13.1 MB 49 kB/s
Collecting torchaudio==0.7.2
Downloading https://github.com/KumaTea/pytorch-aarch64/releases/download/v1.7.1/torchaudio-0.7.2-cp37-cp37m-linux_aarch64.whl (6.6 MB)
|████████████████████████████████| 6.6 MB 5.9 MB/s
Collecting numpy
Downloading numpy-1.21.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (13.0 MB)
|████████████████████████████████| 13.0 MB 137 kB/s
Collecting typing-extensions
Downloading typing_extensions-3.10.0.2-py3-none-any.whl (26 kB)
Collecting pillow>=4.1.1
Downloading Pillow-8.3.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.9 MB)
|████████████████████████████████| 2.9 MB 4.4 MB/s
Installing collected packages: typing-extensions, numpy, torch, pillow, torchvision, torchaudio
Successfully installed numpy-1.21.2 pillow-8.3.1 torch-1.7.1 torchaudio-0.7.2 torchvision-0.8.2 typing-extensions-3.10.0.2

查看已经安装好的Torch

(base) pi@raspbian:~/Software$ pip list
Package Version
---------------------- -------------------
brotlipy 0.7.0
certifi 2020.12.5
cffi 1.14.5
chardet 4.0.0
conda 4.9.2
conda-package-handling 1.7.2
cryptography 3.3.1
idna 2.10
numpy 1.21.2
Pillow 8.3.1
pip 21.0.1
pycosat 0.6.3
pycparser 2.20
pyOpenSSL 20.0.1
PySocks 1.7.1
requests 2.25.1
ruamel-yaml-conda 0.15.80
setuptools 52.0.0.post20210302
six 1.15.0
torch 1.7.1
torchaudio 0.7.2
torchvision 0.8.2
tqdm 4.59.0
typing-extensions 3.10.0.2
urllib3 1.26.4
wheel 0.36.2

查看Torch是否安装成功

(base) pi@raspbian:~/Software$ python
Python 3.7.10 (default, Mar 15 2021, 20:52:10)
[GCC 10.2.0] :: Anaconda, Inc. on linux
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import torch
>>> torch.version
‘1.7.1’
>>>