Below are pre-built PyTorch pip wheel installers for Jetson Nano, TX1/TX2, Xavier, and Orin 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). You can also use the containers from jetson-containers.
PyTorch pip wheels
JetPack 6
PyTorch v2.3.0
-
JetPack 6.0 (L4T R36.2 / R36.3) + CUDA 12.2
- torch 2.3 -
torch-2.3.0-cp310-cp310-linux_aarch64.whl
- torchaudio 2.3 -
torchaudio-2.3.0+952ea74-cp310-cp310-linux_aarch64.whl
- torchvision 0.18 -
torchvision-0.18.0a0+6043bc2-cp310-cp310-linux_aarch64.whl
- torch 2.3 -
-
JetPack 6.0 (L4T R36.2 / R36.3) + CUDA 12.4
- torch 2.3 -
torch-2.3.0-cp310-cp310-linux_aarch64.whl
- torchaudio 2.3 -
torchaudio-2.3.0+952ea74-cp310-cp310-linux_aarch64.whl
- torchvision 0.18 -
torchvision-0.18.0a0+6043bc2-cp310-cp310-linux_aarch64.whl
- torch 2.3 -
PyTorch v2.2.0
- JetPack 6.0 DP (L4T R36.2.0)
PyTorch v2.1.0
- JetPack 6.0 DP (L4T R36.2.0)
- Python 3.10 -
torch-2.1.0-cp310-cp310-linux_aarch64.whl
(USE_DISTRIBUTED=on)
- Python 3.10 -
JetPack 5
PyTorch v2.1.0
- JetPack 5.1 (L4T R35.2.1) / JetPack 5.1.1 (L4T R35.3.1) / JetPack 5.1.2 (L4T R35.4.1)
PyTorch v2.0.0
- JetPack 5.1 (L4T R35.2.1) / JetPack 5.1.1 (L4T R35.3.1)
- Python 3.8 -
torch-2.0.0+nv23.05-cp38-cp38-linux_aarch64.whl
- Python 3.8 -
PyTorch v1.14.0
- JetPack 5.1 (L4T R35.2.1) / JetPack 5.1.1 (L4T R35.3.1)
PyTorch v1.13.0
- JetPack 5.0 (L4T R34.1) / JetPack 5.0.2 (L4T R35.1) / JetPack 5.1 (L4T R35.2.1) / JetPack 5.1.1 (L4T R35.3.1)
PyTorch v1.12.0
- JetPack 5.0 (L4T R34.1) / JetPack 5.0.2 (L4T R35.1) / JetPack 5.1 (L4T R35.2.1) / JetPack 5.1.1 (L4T R35.3.1)
PyTorch v1.11.0
- JetPack 5.0 (L4T R34.1) / JetPack 5.0.2 (L4T R35.1) / JetPack 5.1 (L4T R35.2.1) / JetPack 5.1.1 (L4T R35.3.1)
- Python 3.8 -
torch-1.11.0-cp38-cp38-linux_aarch64.whl
- Python 3.8 -
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)
- Python 3.6 -
torch-1.10.0-cp36-cp36m-linux_aarch64.whl
- This is the final PyTorch release supporting Python 3.6.
- Python 3.6 -
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
- Python 3.6 -
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
- Python 3.6 -
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
- Python 3.6 -
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.
- Python 3.6 -
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
- Python 3.6 -
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
- Python 2.7 -
-
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
- Python 2.7 -
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
- Python 2.7 -
-
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
- Python 2.7 -
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
- Python 2.7 -
-
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
- Python 2.7 -
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
- Python 2.7 -
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
- Python 2.7 -
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.
- PyTorch 1.11 -
pytorch-1-11-jetpack-5-0.patch
- PyTorch 1.10 -
pytorch-1.10-jetpack-4.5.1.patch
- PyTorch 1.9 -
pytorch-1.9-jetpack-4.5.1.patch
- PyTorch 1.8 -
pytorch-1.8-jetpack-4.4.1.patch
- PyTorch 1.7 -
pytorch-1-7-jetpack-4.4.1.patch
- PyTorch 1.6 -
pytorch-1.6-jetpack-4.4.patch
- PyTorch 1.5 -
pytorch-1.5-jetpack-4.4.patch
- PyTorch 1.4 -
pytorch-1.4-jetpack-4.4.patch
- PyTorch 1.3 -
pytorch-1.3-jetpack-4.2.patch
If you are applying one of the above patches to a different version of PyTorch, the file line locations may have changed, so it is recommended to apply these changes by hand.
Set Build Options
$ export USE_NCCL=0
$ export USE_DISTRIBUTED=0 # skip setting this if you want to enable OpenMPI backend
$ export USE_QNNPACK=0
$ export USE_PYTORCH_QNNPACK=0
$ export TORCH_CUDA_ARCH_LIST="5.3;6.2;7.2" # or "7.2;8.7" for JetPack 5 wheels for Xavier/Orin
$ export PYTORCH_BUILD_VERSION=<version> # without the leading 'v', e.g. 1.3.0 for PyTorch v1.3.0
$ export PYTORCH_BUILD_NUMBER=1
(remember to re-export these environment variables if you change terminal)
Build wheel for Python 2.7 (to pytorch/dist)
$ sudo apt-get install python-pip cmake libopenblas-dev libopenmpi-dev
$ pip install -U pip
$ sudo pip install -U setuptools
$ sudo pip install -r requirements.txt
$ pip install scikit-build --user
$ pip install ninja --user
$ python setup.py bdist_wheel
Build wheel for Python 3.6 (to pytorch/dist)
$ sudo apt-get install python3-pip cmake libopenblas-dev libopenmpi-dev
$ pip3 install -r requirements.txt
$ pip3 install scikit-build
$ pip3 install ninja
$ python3 setup.py bdist_wheel
Note on Upgrading pip
If you get this error from pip/pip3 after upgrading pip with “pip install -U pip”:
pip
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
ImportError
: cannot import name 'main'
You can either downgrade pip to it’s original version:
# Python 2.7
$ sudo python -m pip uninstall pip && sudo apt install python-pip --reinstall
# Python 3.6
$ sudo python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall
-or- you can patch /usr/bin/pip (or /usr/bin/pip3)
diff --git a/pip b/pip
index 56bbb2b..62f26b9 100755
--- a/pip
+++ b/pip
@@ -6,6 +6,6 @@ import sys
# Run the main entry point, similarly to how setuptools does it, but because
# we didn't install the actual entry point from setup.py, don't use the
# pkg_resources API.
-from pip import main
+from pip import __main__
if __name__ == '__main__':
- sys.exit(main())
+ sys.exit(__main__._main())