Torchvision issues for import torchvision.transforms

I have installed pytorch as shown in nvidia documents and follwed procedure for torchvision for 0.15.1 as torch is 2.0.0+nv

$ sudo apt-get install libjpeg-dev zlib1g-dev libpython3-dev libopenblas-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

got log finally

Using /usr/local/lib/python3.8/dist-packages
Finished processing dependencies for torchvision==0.15.1a0+42759b1

by when i am trying to check i am getting issues 

adascoe@ubuntu:~/Rail_road_activity$ python3
Python 3.8.10 (default, May 26 2023, 14:05:08) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torchvision.transforms
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'torchvision.transforms'
>>> import torchvision
>>> torchvision,__version__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name '__version__' is not defined
>>> torchvision.__version__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'torchvision' has no attribute '__version__'
>>> print(torchvision.__version__)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'torchvision' has no attribute '__version__'

Can anyone please help me

Hi @anudeep.kamepalli, does your torchvision source directory happen to be under ~/Rail_road_activity ? If so, try changing to a different directory when you run your test commands. Otherwise it can try to import from that folder as opposed to the module.

What does cd / && pip3 show torchvision show?

My location where i installed is adascoe@ubuntu:~/Rail_road_activity$ cd yolov5-master/

adascoe@ubuntu:~$ pip3 show torchvision
WARNING: Package(s) not found: torchvision
adascoe@ubuntu:~$ sudo pip3 show torchvision
[sudo] password for adascoe:
Name: torchvision
Version: 0.15.1a0+42759b1
Summary: image and video datasets and models for torch deep learning
Home-page: GitHub - pytorch/vision: Datasets, Transforms and Models specific to Computer Vision
Author: PyTorch Core Team
License: BSD
Location: /root/.local/lib/python3.8/site-packages/torchvision-0.15.1a0+42759b1-py3.8-linux-aarch64.egg
Requires: numpy, pillow, requests, torch
adascoe@ubuntu:~$ cd Rail_road_activity/
adascoe@ubuntu:~/Rail_road_activity$ cd y
bash: cd: y: No such file or directory
adascoe@ubuntu:~/Rail_road_activity$ cd yolov5-master/

@anudeep.kamepalli it appears that it was installed with sudo and is under /root, which is why your normal user can’t see it. Try running python3 install without sudo.

Or you can just build the wheel and save it, to keep having to avoid building torchvision while you are debugging this issue:

python3 --verbose bdist_wheel
pip3 install dist/torchvision*.whl

thanks a lot @dusty_nv

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