Below are pre-built PyTorch pip wheel installers for Python on Jetson Nano, Jetson TX1/TX2, and Jetson Xavier NX/AGX with JetPack 4.2 and newer.
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).
PyTorch pip wheels
PyTorch v1.9.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.9.0-cp36-cp36m-linux_aarch64.whl
PyTorch v1.8.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.8.0-cp36-cp36m-linux_aarch64.whl
PyTorch v1.7.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.7.0-cp36-cp36m-linux_aarch64.whl
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
- JetPack 4.4 Developer Preview (L4T R32.4.2)
- Python 3.6 - torch-1.5.0-cp36-cp36m-linux_aarch64.whl
- As per the PyTorch Release Notes, Python 2 is not longer supported
PyTorch v1.4.0
- JetPack 4.4 Developer Preview (L4T R32.4.2)
- Python 2.7 - torch-1.4.0-cp27-cp27mu-linux_aarch64.whl
- Python 3.6 - torch-1.4.0-cp36-cp36m-linux_aarch64.whl
- JetPack 4.2 / 4.3
- Python 2.7 - torch-1.4.0-cp27-cp27mu-linux_aarch64.whl
- Python 3.6 - torch-1.4.0-cp36-cp36m-linux_aarch64.whl
PyTorch v1.3.0
- JetPack 4.4 Developer Preview (L4T R32.4.2)
- Python 2.7 - torch-1.3.0-cp27-cp27mu-linux_aarch64.whl
- Python 3.6 - torch-1.3.0-cp36-cp36m-linux_aarch64.whl
- JetPack 4.2 / 4.3
- Python 2.7 - torch-1.3.0-cp27-cp27mu-linux_aarch64.whl
- Python 3.6 - torch-1.3.0-cp36-cp36m-linux_aarch64.whl
PyTorch v1.2.0
- JetPack 4.4 Developer Preview (L4T R32.4.2)
- Python 2.7 - torch-1.2.0-cp27-cp27mu-linux_aarch64.whl
- Python 3.6 - torch-1.2.0-cp36-cp36m-linux_aarch64.whl
- JetPack 4.2 / 4.3
- Python 2.7 - torch-1.2.0a0+8554416-cp27-cp27mu-linux_aarch64.whl
- Python 3.6 - torch-1.2.0a0+8554416-cp36-cp36m-linux_aarch64.whl
PyTorch v1.1.0
- JetPack 4.2 / 4.3
- Python 2.7 - torch-1.1.0-cp27-cp27mu-linux_aarch64.whl
- Python 3.6 - torch-1.1.0-cp36-cp36m-linux_aarch64.whl
PyTorch v1.0.0
- JetPack 4.2 / 4.3
- Python 2.7 - torch-1.0.0a0+bb15580-cp27-cp27mu-linux_aarch64.whl
- Python 3.6 - torch-1.0.0a0+bb15580-cp36-cp36m-linux_aarch64.whl
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.6, torch v1.8
$ 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
$ pip3 install Cython
$ pip3 install numpy torch-1.8.0-cp36-cp36m-linux_aarch64.whl
> Python 2.7, torch v1.4
$ 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
$ 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 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
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__)
ref.
https://forums.developer.nvidia.com/t/pytorch-for-jetson-version-1-9-0-now-available/72048
https://ropiens.tistory.com/68