一、官网下载安装包
NVIDIA官网:https://forums.developer.nvidia.com/t/pytorch-for-jetson-version-1-7-0-now-available/72048
可以根据个人需求下载不同版本的Pytorch安装包,建议科学上网。
# 安装指令
sudo pip3 install torch-1.7.0-cp36-cp36m-linux_aarch64.whl
二、验证torch
>>> import torch
>>> print(torch.__version__)
1.6.0
>>> print('CUDA availabel: ' + str(torch.cuda.is_available()))
CUDA availabel: True
>>> a = torch.cuda.FloatTensor(2).zero_()
>>> print('Tensor a = ' + str(a))
Tensor a = tensor([0., 0.], device='cuda:0')
>>> b = torch.randn(2).cuda()
>>> print('Tensor b = ' + str(b))
Tensor b = tensor([-0.5447, 1.9535], device='cuda:0')
>>> c = a + b
>>> print('Tensor c = ' + str(c))
Tensor c = tensor([-0.5447, 1.9535], device='cuda:0')
>>>
三、安装torchvision
torchvision githup地址:https://github.com/pytorch/vision
# 安装一些必要的包
sudo apt-get install libjpeg-dev zlib1g-dev
# 下载torchvision
git clone -b v0.7.0 https://github.com/pytorch/vision torchvision
# 安装torchvision
cd torchvision
sudo python3 setup.py install
根据个人需求安装对应的版本
最后测试一下torchvision
import torchvision
print(torchvision.__version__)
四、解决Error
安装torch过程中遇到缺少别的安装包
比如libmpi_cxx.so.20和libhwloc.so.5
可以到这个网站https://pkgs.org/去下载对应的安装包再进行安装即可
进入pkgs网站,右上角搜索缺少的库,选择操作系统对应的版本,点击进入下载和安装页面
进入到下载和安装页面
安装有两种方式
1.官网提出的使用apt-get安装
sudo apt-get install libopenmpi2
2.使用dpkg安装指令进行安装
dpkg -i libopenmpi2_2.1.1-8_arm64.deb
安装完之后,再次进行torch测试还会提示缺少别的包,操作如上。