PyTorch for Jetson

Below are pre-built PyTorch pip wheel installers for Python on Jetson Nano, Jetson TX1/TX2, Jetson Xavier NX/AGX, and Jetson AGX 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 pre-built l4t-pytorch and l4t-ml container images and Dockerfiles.

PyTorch pip wheels

PyTorch v1.12.0
PyTorch v1.11.0
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



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

wget -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
pip3 install numpy torch-1.8.0-cp36-cp36m-linux_aarch64.whl

> Python 2.7

wget -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> 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 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


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>
$ 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.

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 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

(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 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 bdist_wheel
Note on Upgrading pip

If you get this error from pip/pip3 after upgrading pip with “pip install -U pip”:

Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
: 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, 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())
Can I use c++ torch, tensorrt in Jetson Xavier at the same time?
Importing PyTorch fails in L4T R32.3.1 Docker image on Jetson Nano after successful install
Pytorch resulting in segfault when calling convert
installing of retina-net-examples on Jetson Xavier
Installing Torch Vision of Jetson Nano
Difficulty Installing Pytorch on Jetson Nano
Pytorch and CUDA on Jetson Xavier NX
Using YOLOv5 on AGX uses the CPU and not the GPU
torch@Xavier NX
Pytorch GPU support for python 3.7 on Jetson Nano
How to install Pytorch 1.7 with cuDNN 10.2?
Installing PyTorch for CUDA 10.2 on Jetson Xavier NX for YOLOv5
Torch install issue
PyTorch for JetPack 4.4 - L4T R32.4.3 in Jetson Xavier NX
How to build libtorch on jetsonTX2?
Train custom object detectio model
Error : torch-1.7.0-cp36-cp36m-linux_aarch64.whl is not a supported wheel on this platform
How do I install pytorch 1.5.0 on the jetson nano devkit?
Error when install torchvision on TX2
Anyone had luck installing Detectron2 on a TX2 (Jetpack 4.2)?
Build PyTorch 1.6.0 from source for DRIVE AGX Xavier - failed undefined reference to "cusparseSpMM"
LIBTORCH with cxx11 ABI support
RuntimeError: Didn't find engine for operation quantized::conv2d_prepack NoQEngine
Illegal instruction (core dumped)
Hello AI World on Jetpack 4.4
Install PyTorch with Python 3.8 on Jetpack 4.4.1
How to to install cuda 10.0 on jetson nano separately ?
CUDA not detected when building Torch Examples on DeepStream Docker container
Torch.cuda.is_available() returns false
Pytorch release memory problem
MatchboxNet on JetsonNano
How to import torchvision.models.detection
Installing older version of Pytorch
Jetson nano GPU is not working?
Not able to install torchvision v0.6.0 on Jetson jetson xavier nx
Jetpack 4.6 L4T 32.6.1 allows pytorch cuda support
Darknet slower using Jetpack 4.4 (cuDNN 8.0.0 / CUDA 10.2) than Jetpack 4.3 (cuDNN 7.6.3 / CUDA 10.0)
Do Jetson Xavier support PyTorch C++ API?
TensorFlow JupyterLab Hello AI world
Problems intalling Pytorch
Cuda hangs after installation of jetpack and reboot Error
Pytorch 1.7 nan results
Unable to set up detectron2 on Jetson NX
PyTorch 1.11 for JetPack 5.0 DP?
How to run Pytorch trained MaskRCNN (detectron2) with TensorRT
AGX Xavier torchvision installation
How to cuda cores while using pytorch models ? only in cpu mode i can run my program which takes more time
Torchvision will not import into Python after jetson-inference build of PyTorch
How to install YoloV5 on Jetson AGX Orin
Any complete installation guide for "deepstream_pose_estimation"?
Pytorch on Jetson nano Jetpack 4.4 R32.4.4
AssertionError: CUDA unavailable, invalid device 0 requested on jetson Nano
Can I install pytorch v1.8.1 on my orin(v1.12.0 is recommended)?
How to download pyTorch 1.5.1 in jetson xavier
Jeton Nano Jetpack 5.0.2 support
I cannot train a detection model. I get the error: RuntimeError: Error in loading state_dict for SSD: Unexpected key(s) in state_dict:
Python3 --data=data/fruit --model-dir=models/fruit --batch-size=4 --epochs=30
How to compile Caffe in jettpack 4.4?
Workspace Size Error by Multiple Conv+Relu Merging on DRIVE AGX
Calling cuda() consumes all the RAM memory
Segmentation fault(core dumped) error while importing torch
Pytorch Installation issue on Jetson Nano
My jetson nano board returns 'False' to torch.cuda.is_available() in local directory
Installing Pytorch OSError: cannot open shared object file: No such file or directory
Cannot install deepspeed on AGX Xavier
Pytorch and Python 3.8 on Jetson NX
OSError about while importing torch to Xavier
Install PyTorch with Python 3.8 on Jetpack 4.4.1
An error occurred while importing pytorch
Documentation link question
Import torch, shows error on xavier that called problem
How to download PyTorch 1.9.0 in Jetson Xavier nx?
PyTorch inference on tensors of a particular size cause Illegal Instruction (core dumped) on Jetson Nano
Every time when i load a model on GPU the code will stuck at there
ERROR: torch-1.6.0-cp36-cp36m-linux_aarch64.whl is not asupported wheel on this platform
Libtorch install on Jetson Xavier NX Developer Ket (C++ compatibility)
ImportError: cannot import name 'USE_GLOBAL_DEPS'
PyTorch/sigmoid error on Tegra
Tensorrt runtime creation takes 2 Gb when torch is imported
When I import pytorch, ImportError: cannot open shared object file: No such file or directory
AssertionError: Torch not compiled with CUDA enabled
AssertionError: Torch not compiled with CUDA enabled
AssertionError: Torch not compiled with CUDA enabled
TorchVision not found error after successful installation
Couple of issues - Cuda/easyOCR & SD card backup
Can I execute yolov5 on the GPU of JETSON AGX XAVIER?
Potential performance and FPS capabilities
AssertionError: Torch not compiled with CUDA enabled
Jetson Xavier torchvision import and installation error
CUDA/NVCC cannot be found. pytorch.cuda.not available
Jetson AGX Xavier Pytorch Wheel files for latest Python 3.8/3.9 versions with CUDA 10.2 support
How exactly does one install and use Libtorch on the AGX Xavier?
Jetson AGX Xavier Pytorch Wheel files for latest Python 3.8/3.9 versions with CUDA 10.2 support
Yolov5 + TensorRT results seems weird on Jetson Nano 4GB
Installing pytorch - /usr/local/cuda/lib64/ error adding symbols: File in wrong format collect2: error: ld returned 1 exit status
OSError: while importing torch
Pytorch and torchvision compatability error
Error in pytorch & torchvision on Xavier NX JP 5.0.1 DP
Running PyTorch CUDA
Jetson AGX XAVIER with jetpack 4.6 installs torch and cuda
Can not use yolov5 batch inference
Pytorch and torchvision
Can I execute yolov5 on the GPU of JETSON AGX XAVIER?
Orin AGX run YOLOV5,ERROR MSG "RuntimeError: Couldn't load custom C++ ops..."
Torch not detecting GPU
Pytorch Driving Guardian
OSError: cannot open shared object file: No such file or directory
YOLOv5 on Jetson Orin not use GPU
Tensorrt runtime creation takes 2 Gb when torch is imported
Installing Jetpack 4.4DP
Jetson Nano L4T 32.3.1 and yolov7 compatibility
Not able to install Pytorch in jetson nano
PyTorch and torchvision versions are incompatible
Error while compiling Libtorch 1.8 on Jetson AGX Xavier
Troubles in installing PyTorch on Jetbot
Jetson Nano - using old version pytorch model
ModuleNotFoundError: No module named 'torch'
Problem in installing torch in Jetson AGX Orin
Embedded Realtime Neural Audio Synthesis using a Jetson Nano
Unable to use GPU with pytorch yolov5 on jetson nano
Install older version of pyotrch on jetpack 4.5.1
Pytorch install failed
Fail while booting TX1
ERROR: Flash Jetson Xavier NX - flash: [error]: : [exec_command]: /bin/bash -c /tmp/; [error]:
ERROR: torch-1.6.0-cp36-cp36m-linux_aarch64.whl is not asupported wheel on this platform
Is there a Pip installable version of TorchVision for Jetson AGX Orin?
Text Recognition Issues
How to install pytorch 1.9 or below in jetson orin
Problems with torch and torchvision Jetson Nano
Problems with torch and torchvision Jetson Nano
Cuda runtime error while re-training SSD
Jetson Nano Jetbot Install "create-sdcard-image-from-scratch" pytorch vision error
Couple of issues - Cuda/easyOCR & SD card backup
Pytorch installation Issue
Best way to install LibTorch?
Nvidia torch + cuda produces only NAN on CPU
Unable to install Torchvision 0.10.0 on Jetson Nano
About PyTorch for Jetpack4.5.2
Building torch with cuda 10 support on Jetpack 5.0 (cuda 11)
Problems Training Models
Segmentation Fault on AGX Xavier but not on other machine
Install torchvision on jetson orin
Jetson AGX Xavier Machine Stuck at Boot
Dancing2Music Application in Jetson Xavier_NX
Pytorch Lightning set up on Jetson Nano/Xavier NX
JetPack 4.4 Developer Preview - L4T R32.4.2 released
Numpy linked to a BLAS implementation
How long i expect to build pytorch on agx xavier ,its building from an hour
Build the pytorch from source for drive agx xavier
Build the pytorch from source for drive agx xavier
Build the pytorch from source for drive agx xavier
Nano B01 crashes while installing PyTorch
How to install pytorch1.5.1?
Installing Pytorch OSError: cannot open shared object file: No such file or directory
Pose Estimation with DeepStream does not work
Troubles in installing PyTorch on Jetbot
Installing pytorch on jetson nano
TRT model generation on DriveOrin fails
ImportError: cannot open shared object file: No such file or directory
PyTorch 1.4 for Python2.7 on Jetpack 4.4.1[L4T 32.4.4]
Failed to install jupyter, got error code 1 in /tmp/pip-build-81nxy1eu/cffi/
How to install torchvision0.8.0 in Jetson TX2 (Jetpack4.5.1,pytorch1.7.0)
Docker image for deepstream and pytorch
GPU running
Pytorch Installation failure in AGX Xavier with Jetpack 5
Jetpack 4.4 Broke one of my programs
No module named torch.fx (torch 1.7.0)
Can I use d2go made by facebook AI on jetson nano?
Installing Pytorch in Orin ( issue)
Building Pytorch from source for Drive AGX
PyTorch doesn't see Cuda device
From fastai import * ModuleNotFoundError: No module named 'fastai'
Jetson Xavier NX has an error when installing torchvision
Jetson Nano Torch 1.6.0 PyTorch Vision v0.7.0-rc2 Runtime Error
Pytorch Lightning set up on Jetson Nano/Xavier NX
PyTorch Install problem (Solved)
Couldn't install detectron2 on jetson nano
How do I install pynvjpeg in an NVIDIA L4T PyTorch container(l4t-pytorch:r32.5.0-pth1.7-py3)?
Detectron2 for Nvidia Jetson Nano
Cannot install PyTorch on Jetson Xavier NX Developer Kit
Jetson model training on WSL2 Docker container - issues and approach
Torch not compiled with cuda enabled over Jetson Xavier Nx
Performance impact with jit coverted model using by libtorch on Jetson Xavier
Cannot install pytorch
PyTorch and GLIBC compatibility error after upgrading JetPack to 4.5
Libtorch CUDA Problem
Glibc”2.28” not found when using torch1.6.0
YOLOv5 performance on Jetson Xavier AGX
Fastai (v2) not working with Jetson Xavier NX
Can not upgrade to tourchvision 0.7.0 from 0.2.2.post3
Can not upgrade to tourchvision 0.7.0 from 0.2.2.post3
Fastai (v2) not working with Jetson Xavier NX
Re-trained Pytorch Mask-RCNN inferencing in Jetson Nano
Re-Trained Pytorch Mask-RCNN inferencing on Jetson Nano
Build Pytorch on Jetson Xavier NX fails when building caffe2
Installed nvidia-l4t-bootloader package post-installation script subprocess returned error exit status 1
Installed nvidia-l4t-bootloader package post-installation script subprocess returned error exit status 1
Cuda runtime error while re-training SSD
Training a model on AGX Xavier
Error occur while JetPack upgrade
How to install facenet-pytorch?

I met a trouble on installing Pytorch.
The Numpy module need python3-dev, but I can’t find ARM python3-dev for Python3.6. The source only includes the ARM python3-dev for Python3.5.1-3.
So, can the Python3.6 Pytorch work on Python3.5? Or where can I find ARM python3-dev for Python3.6 which is needed to install numpy?
Thanks a lot


Hmm that’s strange, on my system ‘sudo apt-get install python3-dev’ shows python3-dev version 3.6.7-1~18.04 is installed. Does it help if you run ‘sudo apt-get update’ before?


If I may ask, is there any way we could get the binaries for the Pytorch C++ frontend? I’m trying to build it from source and that would be really nice.


1 Like

I’m not sure that these are included in the distributable wheel since that’s intended for Python - so you may need to build following the instructions above, but with “python develop” or “python install” in the final step (see here).

@dusty_nv theres a small typo in the verification example, you’ll want to “import torch” not “pytorch”

Could be worth adding the “pip3 install numpy” into the steps, it worked for me first time, I didn’t hit the problem @buptwlr did with python3-dev being missing.

For python2 I had to “pip install future” before I could import torch (was complaining with “ImportError: No module named builtins”), apart from that it looks like its working as intended.

Thanks !!

1 Like

Woops, thanks for pointing that out Balnog, I have fixed that in the steps above.

Do you think that is only needed if you are building from source, or do you need to explicitly install numpy even if just using the wheel?

1 Like

I had to install numpy when using the python3 wheel. It wasn’t necessary for python2 - I’d not installed anything other than pip/pip3 on the system at that point (using the latest SD card image).

@dusty_nv , @Balnog
I have found the solution. I changed the apt source for speed reason.
And after putting the original sources back to the sources.list file, I successfully find the apt package.

OK thanks, I updated the pip3 install instructions to include numpy in case other users have this issue.

1 Like

from china
burn in jetson-nano-sd-r32.1-2019-03-18.img today.
download torch-1.1.0a0+b457266-cp36-cp36m-linux_aarch64.whl

-bash: pip3: command not found

do I need to install pip3?

sudo apt-get update failed.

python3-pip or python3-dev can’t be located.

edit /etc/apt/source.list to Chinese images failed again.


Hi huhai, if apt-get update failed, that would prevent you from installing more packages from Ubuntu repo. Are you behind a firewall that is preventing you from connecting to the Ubuntu package repositories?

pip3 installed using:
referencing :

pip3 install numpy stlll failed.

restored /etc/apt/sources.list
apt-get work fine. Its the network , should be.
reinstalled pip3

numpy installed ok using:
pip3 install numpy --user

Playing ubuntu 16.04 and pytorch on this network for a while already, apt-get works well before.

New to ubuntu 18.04 and arm port, will keep working on apt-get .

turn out the wheel file can’t be download from china.
the file downloaded before have zero byte.
using an aliyun esc in usa finished the download job.

finally pytorch installed.


PS: compiling pytorch using jetson nano is a nightmare .

@dusty_nv ,
Hi, could you tell me how to install torchvision?
I cant install it by “pip3 install torchvision” cause it would collecting torch(from torchvision), and PyTorch does not currently provide packages for PyPI.

Please help me out. Thanks a lot

Hi buptwlr, run the commands below to install torchvision. It is installed from source:

$ git clone
$ cd vision
$ sudo python install
1 Like

When installing torchvision, I found I needed to install libjpeg-dev (using sudo apt-get install libjpeg-dev) becaue it’s required by Pillow which in turn is required by torchvision.

I’m getting a weird error while importing. I installed using the pre-built wheel specified in the top post.

>>> import torch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/nvidia/python3/lib/python3.6/site-packages/torch/", line 97, in <module>
    from torch._C import *
ImportError: cannot open shared object file: No such file or directory

I’m using a Xavier with the following CUDA version.

>>> cat /usr/local/cuda-10.0/version.txt 
CUDA Version 10.0.117

Hi haranbolt, have you re-flashed your Xavier with JetPack 4.2? Are you able to find cusparse library?

I had flashed it using JetPack 4.1.1 Developer preview. Is it necessary to reflash it using JetPack 4.2?

Yes, these PyTorch pip wheels were built against JetPack 4.2.