PyTorch and torchvision on Jetson Orin

Hey all! I have a jetson Orin with the latest jetpack version (5.1). I’m trying to install tensorflow, opencv, pytorch and torchvision for a computer vision project.

So far, I have successfully installed the latest OpenCV version (4.7.0) with CUDA and cuDNN enabled using Python 3.8.

I’ve followed these instructions to install Pytorch but I can’t seem to find the right version for torchvision, at least according to this documentation. I can only find the compatibility of Pytorch 1.13.0 with torchvision 0.14.0 but not for Pytorch 1.14.

I plan to install tensorflow 2 and Yolov7, so the installed PyTorch should be >1.7 but not 1.12 and the installed version of torchvision should be >0.8 but not 0.13.

Apart from this, when trying to find an older version of PyTorch to install, I can’t seem to find any for the Jetpack version I currently have (5.1) based on the link provided.

Is there any compatibility table that I could use to locate the right versions? Could you please provide any instructions available to install the above-mentioned?

Hi @christina.malliou, for PyTorch 1.14 it looks like I used torchvision 0.14, but I think there is some flexibility there. More important is that you build torchvision from source rather than install it from a PyPi binary wheel (those won’t be built with CUDA enabled):

$ 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

Also, given all your dependencies, you might just want to base your project off the l4t-ml container: https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-ml it comes with PyTorch, torchvision, TensorFlow, and OpenCV pre-installed.

1 Like

Thank you @dusty_nv ! I’ve seen one of your older posts on how to install torchvision and I was planning to follow the instructions that you have provided!

I finally managed to install everything and have everything working, but I might give a try to the container as well! The only “issue” that I run into was that I can’t import OpenCV before importing Tensorflow.

I couldn’t tell you why that is, but I’ve seen cv2 spuriously have import-order package conflicts with other packages in the past - I’m not sure why, and it doesn’t seem specific to Jetson :/

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.