Nvidia Jetson Agx Xavier 折腾笔记之安装pytorch1.6

 

前言

详细信息见官方链接:https://forums.developer.nvidia.com/t/pytorch-for-jetson-nano-version-1-6-0-now-available/72048

本文只介绍python3.6安装,python2.7见上面官方链接

安装 torch for python3.6

选择对应版本:由下图可见,jetpack4.4 对应 pytorch1.6

wget https://nvidia.box.com/shared/static/ncgzus5o23uck9i5oth2n8n06k340l6k.whl -O torch-1.6.0-cp36-cp36m-linux_aarch64.whl

(此处需要科学上网,提供下载好的torch-1.6.0-cp36-cp36m-linux_aarch64.whl:

链接:https://pan.baidu.com/s/1JeeNMkdOgRSTFkqWrTIsLw

提取码:wcue

sudo apt-get install python3-pip libopenblas-base libopenmpi-dev

pip3 install Cython

pip3 install numpy torch-1.6.0-cp36-cp36m-linux_aarch64.whl

(需要等待一段时间,在编译中)

安装torchvision

Pytorch 和 Torchvison 的对应版本

如上图,pytorch对应torchvision v0.7.0,因此git clone --branch <version> https://github.com/pytorch/vision torchvision中的<version> 换成v0.7.0,

安装命令如下:

sudo apt-get install libjpeg-dev zlib1g-dev

git clone --branch v0.7.0 https://github.com/pytorch/vision torchvision # see below for version of torchvision to download

cd torchvision

sudo python3 setup.py install # use python if installing for Python 2.7

cd ../ # attempting to load torchvision from build dir will result in import error

pip install 'pillow<7' # always needed for Python 2.7, not needed torchvision v0.5.0+ with Python 3.6

安装完成,验证一下torch和torchvision

输入 python3 ,启动 Python3.6

>>> import torch
>>> print(torch.__version__)
>>> print('CUDA available: ' + str(torch.cuda.is_available()))
>>> print('cuDNN version: ' + str(torch.backends.cudnn.version()))
>>> 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))

 

>>> import torchvision
>>> print(torchvision.__version__)

参考资料:

1. https://forums.developer.nvidia.com/t/pytorch-for-jetson-nano-version-1-6-0-now-available/72048

 

©️2020 CSDN 皮肤主题: 创作都市 设计师:CSDN官方博客 返回首页