Unable to install pytorch and torchvision on jetson orin

Hello, Im trying to install pytorch and torchvision on jetson orin. I’m trying to install both the dependencies from here and follow all the steps. Although when I run the command python3 setup.py install --user I’m getting an error saying
OSError: libmpi_cxx.so.20: cannot open shared object file: No such file or directory. Any help is appreciated.

Hello @vai95.kavathekar

Could you please try installing the package from jp6/cu126 index?

Also, you could check Jetson/L4T/TRT Customized Example - eLinux.org for guidance.

I hope this helps!
Regards!
Eduardo Salazar
Embedded SW Engineer at RidgeRun

Contact us: support@ridgerun.com
Developers wiki: https://developer.ridgerun.com/
Website: www.ridgerun.com

Thank you for the reply. The first link somehow is not working/not reachable. For the second link; I just had one question would it work for jetpack 5.1? by replacing the torch wheels. My goal is to have a software setup on jetpack 6.1+ only ; but,just making sure I have a working version on jetpack 5.1.

Hello @vai95.kavathekar

Yes, it seems that the link is broken. However, from How to get Pytorch to work on jetson Orin Nano - #5 by AastaLLL they mentioned that they moved the packages for JetPack 6.2 to that link.

@AastaLLL could you please help with the broken link?

For JetPack 5.1, I used the link that you posted, PyTorch for Jetson. So, I would use the packages from there if I needed.

Regards!

Hello @vai95.kavathekar

The link is up again (jp6/cu126 index), at the moment I am writing this reply,

I hope this helps!
Regards!

Hello Eduardo,

Thanks for the reply. I did try with the second link as I reflashed my orin with jetpack 6.2 , although I’m getting the error as below:

Also, that is the cpu version. If I had to install the gpu version for jetpack 6.2 I should follow the same link I posted?

Hello @vai95.kavathekar

For a Jetson with JetPack 6.2 please install the packages at jp6/cu126 index

I tested on a Jetson Orin Nano:

 wget https://pypi.jetson-ai-lab.dev/jp6/cu126/+f/a86/1895294d90440/torch-2.6.0rc1-cp310-cp310-linux_aarch64.whl#sha256=a861895294d90440f2cdbd863d3fd5407fcc346f819665f3a63d90dfcf41a5b0
--2025-02-21 08:17:23--  https://pypi.jetson-ai-lab.dev/jp6/cu126/+f/a86/1895294d90440/torch-2.6.0rc1-cp310-cp310-linux_aarch64.whl
Resolving pypi.jetson-ai-lab.dev (pypi.jetson-ai-lab.dev)... 108.39.248.12
Connecting to pypi.jetson-ai-lab.dev (pypi.jetson-ai-lab.dev)|108.39.248.12|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 240763395 (230M) [None]
Saving to: ‘torch-2.6.0rc1-cp310-cp310-linux_aarch64.whl’

torch-2.6.0rc1-cp310-cp310-li 100%[===============================================>] 229,61M  6,33MB/s    in 32s     

2025-02-21 08:17:55 (7,18 MB/s) - ‘torch-2.6.0rc1-cp310-cp310-linux_aarch64.whl’ saved [240763395/240763395]

nvidia@ubuntu:~$ pip3 install torch-2.6.0rc1-cp310-cp310-linux_aarch64.whl 
Defaulting to user installation because normal site-packages is not writeable
Processing ./torch-2.6.0rc1-cp310-cp310-linux_aarch64.whl
Collecting networkx
  Downloading networkx-3.4.2-py3-none-any.whl (1.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.7/1.7 MB 3.5 MB/s eta 0:00:00
Collecting typing-extensions>=4.10.0
  Downloading typing_extensions-4.12.2-py3-none-any.whl (37 kB)
Collecting sympy==1.13.1
  Downloading sympy-1.13.1-py3-none-any.whl (6.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.2/6.2 MB 6.3 MB/s eta 0:00:00
Collecting filelock
  Downloading filelock-3.17.0-py3-none-any.whl (16 kB)
Collecting jinja2
  Downloading jinja2-3.1.5-py3-none-any.whl (134 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 134.6/134.6 KB 6.1 MB/s eta 0:00:00
Collecting fsspec
  Downloading fsspec-2025.2.0-py3-none-any.whl (184 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 184.5/184.5 KB 6.1 MB/s eta 0:00:00
Collecting mpmath<1.4,>=1.1.0
  Downloading mpmath-1.3.0-py3-none-any.whl (536 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 536.2/536.2 KB 5.9 MB/s eta 0:00:00
Requirement already satisfied: MarkupSafe>=2.0 in /usr/lib/python3/dist-packages (from jinja2->torch==2.6.0rc1) (2.0.1)
Installing collected packages: mpmath, typing-extensions, sympy, networkx, jinja2, fsspec, filelock, torch
  WARNING: The script isympy is installed in '/home/nvidia/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts torchfrtrace and torchrun are installed in '/home/nvidia/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed filelock-3.17.0 fsspec-2025.2.0 jinja2-3.1.5 mpmath-1.3.0 networkx-3.4.2 sympy-1.13.1 torch-2.6.0rc1 typing-extensions-4.12.2
nvidia@ubuntu:~$ python3
Python 3.10.12 (main, Nov  6 2024, 20:22:13) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> 

Regards!

Either create a shell script or copy, paste and run the entire below into a terminal window

#!/usr/bin/env bash

sudo apt update

if [ -d “/usr/local/cuda-12.6” ]; then
sudo apt install -y cuda-cupti-12-6

pip install -U https://pypi.jetson-ai-lab.dev/jp6/cu126/+f/a86/1895294d90440/torch-2.6.0rc1-cp310-cp310-linux_aarch64.whl

pip install -U https://pypi.jetson-ai-lab.dev/jp6/cu126/+f/5f9/67f920de3953f/torchvision-0.20.0-cp310-cp310-linux_aarch64.whl

elif [ -d “/usr/local/cuda-12.8” ]; then
sudo apt install -y cuda-cupti-12-8

pip install -U https://pypi.jetson-ai-lab.dev/jp6/cu128/+f/406/faef6ad009ac1/torch-2.6.0-cp310-cp310-linux_aarch64.whl

pip install -U https://pypi.jetson-ai-lab.dev/jp6/cu128/+f/0d9/ebbd08083f971/torchvision-0.21.0-cp310-cp310-linux_aarch64.whl

else
echo “No recognized CUDA directory. Exiting.”
fi

Okay , Thank you. I was able to install the required versions of pytorch on jetpack 6.2. Although, one of my other device is jetpack 5.1 and I always get some errors while installing pytorch and torchvision even if I follow the exact same steps on the Nvidia forum.



these are the errors

Presuming your JP5.1 has /usr/local/cuda-11.4 you could try these:

pip install -U https://pypi.jetson-ai-lab.dev/jp5/cu114/+f/4c1/d7a5d0ba92527/torch-2.2.0-cp38-cp38-linux_aarch64.whl

pip install -U https://pypi.jetson-ai-lab.dev/jp5/cu114/+f/12c/2173bcd5255bd/torchvision-0.17.2+c1d70fe-cp38-cp38-linux_aarch64.whl

pip install -U https://pypi.jetson-ai-lab.dev/jp5/cu114/+f/edd/edbc352a2b140/torchaudio-2.2.2+cefdb36-cp38-cp38-linux_aarch64.whl

Thank you so much! I was stuck on this since long instead of the actual work. Any recommendations on how to install opencv on cuda properly?

For JP5.1 I think these are the available for opencv

sudo apt install libopencv libopencv-dev \
libopencv-python libopencv-samples \
nvidia-opencv nvidia-opencv-dev opencv-licenses

Run the below open CV script for your respective Jetpack version.