Import torchvision fails on NVIDIA jetson orin nano

Hello,

I am trying to install pytorch and torchvision on my nvidia jetson orin nano. I have referred this guide : Installing PyTorch for Jetson Platform - NVIDIA Docs

Device : NVIDIA Jetson Orin Nano
Jetpack : 5.1.3
Python : 3.8
Pytorch : 2.0.0
torchvision : 0.15.1 (also tried 0.15.2)

Here are the flags during compilation of torchvision:

Building wheel torchvision-0.15.1
Compiling extensions with following flags:
FORCE_CUDA: False
DEBUG: False
TORCHVISION_USE_PNG: True
TORCHVISION_USE_JPEG: True
TORCHVISION_USE_NVJPEG: True
TORCHVISION_USE_FFMPEG: True
TORCHVISION_USE_VIDEO_CODEC: True
NVCC_FLAGS:
Found PNG library
Building torchvision with PNG image support
libpng version: 1.6.37
libpng include path: /usr/include/libpng16
Running build on conda-build: False
Running build on conda: False

torchvision is installed correctly but, when i run import torchvision, to verify the installation, I get the below error:

$python -c “import torchvision; print(torchvision.version)”
Traceback (most recent call last):
File “”, line 1, in
File “/home/chandorkar/.local/lib/python3.8/site-packages/torchvision-0.15.1-py3.8-linux-aarch64.egg/torchvision/init.py”, line 6, in
from torchvision import datasets, io, models, ops, transforms, utils
File “/home/chandorkar/.local/lib/python3.8/site-packages/torchvision-0.15.1-py3.8-linux-aarch64.egg/torchvision/datasets/init.py”, line 1, in
from ._optical_flow import FlyingChairs, FlyingThings3D, HD1K, KittiFlow, Sintel
File “/home/chandorkar/.local/lib/python3.8/site-packages/torchvision-0.15.1-py3.8-linux-aarch64.egg/torchvision/datasets/_optical_flow.py”, line 13, in
from .utils import _read_pfm, verify_str_arg
File “/home/chandorkar/.local/lib/python3.8/site-packages/torchvision-0.15.1-py3.8-linux-aarch64.egg/torchvision/datasets/utils.py”, line 22, in
import requests
File “/home/chandorkar/.local/lib/python3.8/site-packages/requests-2.32.3-py3.8.egg/requests/init.py”, line 43, in
import urllib3
File “/home/chandorkar/.local/lib/python3.8/site-packages/urllib3-2.3.0-py3.8.egg/urllib3/init.py”, line 14, in
from . import exceptions
File “/home/chandorkar/.local/lib/python3.8/site-packages/urllib3-2.3.0-py3.8.egg/urllib3/exceptions.py”, line 26, in
_TYPE_REDUCE_RESULT = tuple[typing.Callable[…, object], tuple[object, …]]
TypeError: ‘type’ object is not subscriptable

So it looks like urllib3 2.3.0 removed support for python 3.8

link to changelog:

Potential solutions:

  • downgrading your urllib3<2
  • upgrading your python version to >3.8

This was all I could find at the moment. Hope this helps!

Thank you :slight_smile: This helped me resolve my issue.