Torchvison compatibility

I was training a YOLOv8 object detection model on my jetson orin nano, and after the first epoch I got the following error message:

AttributeError: partially initialized module ‘torchvision’ has no attribute ‘extension’ (most likely due to a circular import)

I realized my torchvision version was 0.19.0 which is not correct for my torch version which is torch-2.3.0a0+ebedce2. I tried installing 0.18.0 through pip but that uninstalled my torch version and reinstalled torch 2.3.0 without CUDA enabled. Which torchvision version is compatible with torch-2.3.0a0+ebedce2 and how can I install it?

Additionally, I tried using the installation instructions for torchvision from this link (PyTorch for Jetson) but got the following error:

In file included from /home/anaygokhale/torchvision/torchvision/csrc/io/image/cpu/decode_jpeg.cpp:3:
/home/anaygokhale/torchvision/torchvision/csrc/io/image/cpu/exif.h:221:39: error: ‘png_structp’ was not declared in this scope
  221 | inline int fetch_png_exif_orientation(png_structp png_ptr, png_infop info_ptr) {
      |                                       ^~~~~~~~~~~
/home/anaygokhale/torchvision/torchvision/csrc/io/image/cpu/exif.h:221:60: error: ‘png_infop’ was not declared in this scope
  221 | inline int fetch_png_exif_orientation(png_structp png_ptr, png_infop info_ptr) {
      |                                                            ^~~~~~~~~
/home/anaygokhale/torchvision/torchvision/csrc/io/image/cpu/exif.h:221:78: error: expression list treated as compound expression in initializer [-fpermissive]
  221 | inline int fetch_png_exif_orientation(png_structp png_ptr, png_infop info_ptr) {
      |                                                                              ^
error: command '/usr/bin/aarch64-linux-gnu-gcc' failed with exit code 1

Please help me with this issue

Torch vision need to be built from source.
Check below link for more info.

@nagesh_accord But the “Build from Source” section only mentions torch, not torchvision. I tried the torchvision method that is listed under the “Installation” section and that gave me the error that I mentioned in my original post.

Hi,

The command for building TorchVision is at “Installation”.

Thanks.

@AastaLLL As I mentioned in both my previous messages, Those commands did not work for me. I have put the error message in my initial post. Please help me with that issue

Hi,

Which JetPack do you use?
For JetPack 6.0, please install the packages in the topics directly to ensure compatibility.

PyTorch v2.3.0

  • JetPack 6.0 (L4T R36.2 / R36.3) + CUDA 12.2
    ** torch 2.3 - torch-2.3.0-cp310-cp310-linux_aarch64.whl 1.5k
    ** torchaudio 2.3 - torchaudio-2.3.0+952ea74-cp310-cp310-linux_aarch64.whl 622
    ** torchvision 0.18 - torchvision-0.18.0a0+6043bc2-cp310-cp310-linux_aarch64.whl 939

Thanks.

Hello,
What would the correct command be for the installation of the torchvision and torchaudio using the above packages?
The torchvision installation instructions gave me an error as mentioned previously.

Hi

Please try below for the PyTorch:

And below for the TorchAudio and TorchVision:

Thanks.

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