硬件:jetson nano 4G版本

软件:jetson-nano-4gb-jp441-sd-card-image.zip( JP 4.4.1 2020/10/21 )

软件image最新下载地址:https://developer.nvidia.com/jetson-nano-sd-card-image

其他方法的参考连接:https://github.com/dusty-nv/jetson-inference/blob/master/docs/building-repo-2.md

nvidia提供的pytorch发布地址:https://forums.developer.nvidia.com/t/pytorch-for-jetson-version-1-7-0-now-available/72048

我下载了最新版:  PyTorch v1.7.0

JetPack 4.4 (L4T R32.4.3) / JetPack 4.4.1 (L4T R32.4.4)
Python 3.6 – torch-1.7.0-cp36-cp36m-linux_aarch64.whl

下载以后,执行以下命令安装:

sudo apt-get install python3-pip libopenblas-base libopenmpi-dev 
pip3 install Cython
pip3 install numpy
pip3 install numpy torch-1.7.0-cp36-cp36m-linux_aarch64.whl
#测试是否安装成功
import torch
print(torch.__version__)
print('CUDA available: ' + str(torch.cuda.is_available()))
a = torch.cuda.FloatTensor(2).zero_()
print('Tensor a = ' + str(a))
b = torch.randn(2).cuda()
print('Tensor b = ' + str(b))
c = a + b
print('Tensor c = ' + str(c))

安装 torchvision

说明地址:https://github.com/pytorch/vision

因为我安装的是1.7.0的pytorch,对应 torchvision 版本是0.8.1,所以安装如下:

sudo apt-get install libjpeg-dev zlib1g-dev libpython3-dev libavcodec-dev libavformat-dev libswscale-dev
pip3 install torchvision==0.8.1  #我用这条没有安装成功

手动去这个地址下载代码包:https://github.com/pytorch/vision/archive/v0.8.1.zip

解压后,进入文件夹

export BUILD_VERSION=0.8.1
sudo python3 setup.py install 
#测试是否安装成功
import torchvision
print(torchvision.__version__)