Jetson版本下Pytorch和torchvision

Download one of the PyTorch binaries from below for your version of JetPack, and see the installation instructions to run on your Jetson. These pip wheels are built for ARM aarch64 architecture, so run these commands on your Jetson (not on a host PC). You can also use the containers from jetson-containers.

PyTorch pip wheels

JetPack 6

PyTorch v2.3.0

PyTorch v2.2.0

PyTorch v2.1.0

JetPack 5

PyTorch v2.1.0

PyTorch v2.0.0

PyTorch v1.14.0

PyTorch v1.13.0

PyTorch v1.12.0

PyTorch v1.11.0

JetPack 4

PyTorch v1.10.0

  • JetPack 4.4 (L4T R32.4.3) / JetPack 4.4.1 (L4T R32.4.4) / JetPack 4.5 (L4T R32.5.0) / JetPack 4.5.1 (L4T R32.5.1) / JetPack 4.6 (L4T R32.6.1)

PyTorch v1.9.0

PyTorch v1.8.0

PyTorch v1.7.0

PyTorch v1.6.0

  • JetPack 4.4 (L4T R32.4.3) / JetPack 4.4.1 (L4T R32.4.4) / JetPack 4.5 (L4T R32.5.0) / JetPack 4.5.1 (L4T R32.5.1) / JetPack 4.6 (L4T R32.6.1)
    • Python 3.6 - torch-1.6.0-cp36-cp36m-linux_aarch64.whl
    • The JetPack 4.4 production release (L4T R32.4.3) only supports PyTorch 1.6.0 or newer, due to updates in cuDNN.
    • This wheel of the PyTorch 1.6.0 final release replaces the previous wheel of PyTorch 1.6.0-rc2.

PyTorch v1.5.0

PyTorch v1.4.0

PyTorch v1.3.0

PyTorch v1.2.0

PyTorch v1.1.0

PyTorch v1.0.0

Instructions

Installation

Below are example commands for installing these PyTorch wheels on Jetson. Substitute the URL and filenames from the desired PyTorch download from above.

> Python 3

复制代码

# substitute the link URL and wheel filename from the desired torch version above wget https://nvidia.box.com/shared/static/p57jwntv436lfrd78inwl7iml6p13fzh.whl -O torch-1.8.0-cp36-cp36m-linux_aarch64.whl sudo apt-get install python3-pip libopenblas-base libopenmpi-dev libomp-dev pip3 install 'Cython<3' pip3 install numpy torch-1.8.0-cp36-cp36m-linux_aarch64.whl

> Python 2.7

复制代码

# substitute the link URL and wheel filename from the desired torch version above wget https://nvidia.box.com/shared/static/1v2cc4ro6zvsbu0p8h6qcuaqco1qcsif.whl -O torch-1.4.0-cp27-cp27mu-linux_aarch64.whl sudo apt-get install libopenblas-base libopenmpi-dev # skip libopenmpi-dev for PyTorch >= 1.12 pip install future torch-1.4.0-cp27-cp27mu-linux_aarch64.whl

(PyTorch v1.4.0 for L4T R32.4.2 is the last version to support Python 2.7)

> torchvision

复制代码

$ sudo apt-get install libjpeg-dev zlib1g-dev libpython3-dev libopenblas-dev libavcodec-dev libavformat-dev libswscale-dev $ git clone --branch <version> https://github.com/pytorch/vision torchvision # see below for version of torchvision to download $ cd torchvision $ export BUILD_VERSION=0.x.0 # where 0.x.0 is the torchvision version $ python3 setup.py install --user $ 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

Select the version of torchvision to download depending on the version of PyTorch that you have installed:

  • PyTorch v1.0 - torchvision v0.2.2
  • PyTorch v1.1 - torchvision v0.3.0
  • PyTorch v1.2 - torchvision v0.4.0
  • PyTorch v1.3 - torchvision v0.4.2
  • PyTorch v1.4 - torchvision v0.5.0
  • PyTorch v1.5 - torchvision v0.6.0
  • PyTorch v1.6 - torchvision v0.7.0
  • PyTorch v1.7 - torchvision v0.8.1
  • PyTorch v1.8 - torchvision v0.9.0
  • PyTorch v1.9 - torchvision v0.10.0
  • PyTorch v1.10 - torchvision v0.11.1
  • PyTorch v1.11 - torchvision v0.12.0
  • PyTorch v1.12 - torchvision v0.13.0
  • PyTorch v1.13 - torchvision v0.13.0
  • PyTorch v1.14 - torchvision v0.14.1
  • PyTorch v2.0 - torchvision v0.15.1
  • PyTorch v2.1 - torchvision v0.16.1
  • PyTorch v2.2 - torchvision v0.17.1
  • PyTorch v2.3 - torchvision v0.18.0

Verification

To verify that PyTorch has been installed correctly on your system, launch an interactive Python interpreter from terminal (python command for Python 2.7 or python3 for Python 3.6) and run the following commands:

复制代码

>>> 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__) Build from Source

Below are the steps used to build the PyTorch wheels. These were compiled in a couple of hours on a Xavier for Nano, TX2, and Xavier.

Note that if you are trying to build on Nano, you will need to mount a swap file.

Max Performance

复制代码

$ sudo nvpmodel -m 0 # on Xavier NX, use -m 2 instead (15W 6-core mode) $ sudo jetson_clocks

Download PyTorch sources

复制代码

$ git clone --recursive --branch <version> http://github.com/pytorch/pytorch $ cd pytorch

Apply Patch

Select the patch to apply from below based on the version of JetPack you're building on. The patches avoid the "too many CUDA resources requested for launch" error (PyTorch issue #8103, in addition to some version-specific bug fixes.

I

相关推荐
王老师青少年编程17 分钟前
信奥赛C++提高组csp-s知识详解及案例实践(汇总版)
c++·知识·csp·高频考点·信奥赛·csp-s·提高组
2301_7886624023 分钟前
C++中的代理模式高级应用
开发语言·c++·算法
啊阿狸不会拉杆26 分钟前
《计算机操作系统》第十二章 - 保护和安全
开发语言·网络·c++·算法·安全·计算机组成原理·计算机操作系统
月挽清风29 分钟前
代码随想录第十一天
c++·算法·leetcode
郝学胜-神的一滴1 小时前
Linux网络字节序详解:从理论到实践
linux·服务器·c语言·开发语言·c++·网络协议·程序人生
EmbedLinX1 小时前
内存池学习笔记(附C++完整实现)
c++·笔记·学习
Trouvaille ~1 小时前
【Linux】线程概念与控制(一):线程本质与虚拟地址空间
linux·运维·服务器·c++·线程·虚拟地址空间·pcb
难得的我们1 小时前
C++中的状态模式
开发语言·c++·算法
啊阿狸不会拉杆1 小时前
《计算机操作系统》第十章 - 多处理机操作系统
c++·算法·计算机组成原理·os·计算机操作系统
秦苒&2 小时前
【脉脉】AI 创作者 xAMA 知无不言:在浪潮里,做会发光的造浪者
大数据·c语言·数据库·c++·人工智能·ai·操作系统