Torchvision not found - Jetson Inference


For transfer learning :

I have installed pytorch using ./ for python3.6.

When I run in my home directory

$ python3

import torch

import torchvision

I can see these both get imported without any errors.

While re-training model at :

$ cd jetson-inference/python/training/classification

$ python3 --model-dir=(YOUR-MODEL) (PATH-TO-YOUR-DATASET)

I get the error : No module named ‘torchvision’
What could be the possible reason? Do I have to install torchvision separately?

Hmm. If you create a new python script with the following contents, are you able to run it ok?

import torch
import torchvision

Alternatively, if you also install PyTorch for Python 2.7 with, does python ... run ok for you?

Creating new python script and running gives the same error like :

No module named ‘torchvision’ but running Python3 (Version 3.6.9) on terminal and importing (Torch,Torchvision) gives no error!

Installing PyTorch for 2.7 gives error:

I followed the installation procedure same as shown on Github.

Which JetPack version are you on? Do you have python symbolically linked to a different python version than python 2.7?

If you want to try installing PyTorch+torchvision manually, you can find the PyTorch wheels and instructions here:

This message from your screenshot I haven’t seen before: Defaulting to user installation because normal site-packages is not writeable

Is it possible that the permissions of that dir have been changed or corrupted somehow?

Hi Dusty,
Sorry for reaching out to you so late. To avoid all the confusions, I reflashed (Jetpack 4.4)whole device. I installed pytorch from the link you attached.

(I am only using TX2 for Jetson Inference and I haven’t installed or linked python to any other vesion)

I get following error:

Hi @arjunTX2, is it able to import torchvision ok, but not import torchvision.transforms?

What version of torchvision is listed if you print(torchvision.__version__)?

Hi @dusty_nv,
Sorry for the trouble. I have solved this problem.

I was ignoring the error of ‘’ Cache deserialization failed, entry ignored’’ while installing torch. I have removed cache folder and now it is working like charm :D.

Thanks alot.