PyTorch and Torchvision version mismatch for JetPack 5.1.4 on Orin Nano

I am trying to build the local environment for testing yolo11 with TensorRT on my jetson orin nano with jetpack 5.1.4 @ ubuntu20.04

According to the guide , torch-2.1.0a0+41361538.nv23.06-cp38-cp38-linux_aarch64.whl , torchvision v0.16.2 was installed. But I have to downgrade the setuptools==69.5.1 from 75.x.x, otherwise the command python3 setup.py install --user can not be ran. If I use setuptools==75.x.x, I will met:

xliu@ubuntu:~/torchvision$ /usr/bin/python3 setup.py install --user
setup.py:10: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  from pkg_resources import DistributionNotFound, get_distribution, parse_version
Building wheel torchvision-0.16.2+c6f3977
Compiling extensions with following flags:
  FORCE_CUDA: False
  FORCE_MPS: 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: 
Compiling with debug mode OFF
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
Building torchvision with JPEG image support
  libjpeg include path: None
  libjpeg lib path: None
Building torchvision without NVJPEG image support
Building torchvision with ffmpeg support
  ffmpeg version: b"ffmpeg version n4.2.7-24-gd796def2ea-1ubuntu0.1 Copyright (c) 2000-2022 the FFmpeg developers\nbuilt with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.2)\nconfiguration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lv4l2 -lnvbufsurface -lnvbufsurftransform' --extra-cflags=-I/usr/src/jetson_multimedia_api/include/ --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/aarch64-linux-gnu --incdir=/usr/include/aarch64-linux-gnu --arch=arm64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared\nlibavutil      56. 31.100 / 56. 31.100\nlibavcodec     58. 54.100 / 58. 54.100\nlibavformat    58. 29.100 / 58. 29.100\nlibavdevice    58.  8.100 / 58.  8.100\nlibavfilter     7. 57.100 /  7. 57.100\nlibavresample   4.  0.  0 /  4.  0.  0\nlibswscale      5.  5.100 /  5.  5.100\nlibswresample   3.  5.100 /  3.  5.100\nlibpostproc    55.  5.100 / 55.  5.100\n"
  ffmpeg include path: ['/usr/include', '/usr/include/aarch64-linux-gnu']
  ffmpeg library_dir: ['/usr/lib', '/usr/lib/aarch64-linux-gnu']
Building torchvision without video codec support
running install
/home/xliu/.local/lib/python3.8/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!

        ********************************************************************************
        Please avoid running `setup.py directly.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
        ********************************************************************************

!!
  self.initialize_options()
Traceback (most recent call last):
  File "setup.py", line 542, in <module>
    setup(
  File "/home/xliu/.local/lib/python3.8/site-packages/setuptools/__init__.py", line 117, in setup
    return distutils.core.setup(**attrs)
  File "/home/xliu/.local/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 183, in setup
    return run_commands(dist)
  File "/home/xliu/.local/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 199, in run_commands
    dist.run_commands()
  File "/home/xliu/.local/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 954, in run_commands
    self.run_command(cmd)
  File "/home/xliu/.local/lib/python3.8/site-packages/setuptools/dist.py", line 999, in run_command
    super().run_command(command)
  File "/home/xliu/.local/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 972, in run_command
    cmd_obj.ensure_finalized()
  File "/home/xliu/.local/lib/python3.8/site-packages/setuptools/_distutils/cmd.py", line 111, in ensure_finalized
    self.finalize_options()
  File "/home/xliu/.local/lib/python3.8/site-packages/setuptools/command/install.py", line 67, in finalize_options
    super().finalize_options()
  File "/home/xliu/.local/lib/python3.8/site-packages/setuptools/_distutils/command/install.py", line 408, in finalize_options
    'dist_fullname': self.distribution.get_fullname(),
  File "/home/xliu/.local/lib/python3.8/site-packages/setuptools/_core_metadata.py", line 267, in get_fullname
    return _distribution_fullname(self.get_name(), self.get_version())
  File "/home/xliu/.local/lib/python3.8/site-packages/setuptools/_core_metadata.py", line 285, in _distribution_fullname
    canonicalize_version(version, strip_trailing_zero=False),
TypeError: canonicalize_version() got an unexpected keyword argument 'strip_trailing_zero'

After switching setuptools to 69.5.1, the torchvision can be installed successfully:

torch                        2.1.0a0+41361538.nv23.6 /home/xliu/.local/lib/python3.8/site-packages                                            pip
torchvision                  0.16.2                  /home/xliu/.local/lib/python3.8/site-packages/torchvision-0.16.2-py3.8-linux-aarch64.egg

However, the torchvision will post errors:

$ python3 -c "import torch; print(torch.__version__)"
2.1.0a0+41361538.nv23.06

$ python3 -c "import torchvision; print(torchvision.__version__)"
/usr/local/lib/python3.8/dist-packages/torchvision/io/image.py:13: UserWarning: Failed to load image Python extension: '/usr/local/lib/python3.8/dist-packages/torchvision/image.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSsb'If you don't plan on using image functionality from `torchvision.io`, you can ignore this warning. Otherwise, there might be something wrong with your environment. Did you have `libjpeg` or `libpng` installed before building `torchvision` from source?
  warn(
0.16.2+c6f3977

But the required pack like libjpeg and libpng have already been installed in advance.

The same thing happen to other torchvision v0.16.x as well. Any successful experience sharing will be appreciated!

After delete everything and try installing v0.16.1, though the error still exists, tensorRT can be used:

WARNING ⚠️ Unable to automatically guess model task, assuming 'task=detect'. Explicitly define task for your model, i.e. 'task=detect', 'segment', 'classify','pose' or 'obb'.
Loading yolo11n.engine for TensorRT inference...
[12/26/2024-17:51:49] [TRT] [I] Loaded engine size: 11 MiB
[12/26/2024-17:51:49] [TRT] [W] Using an engine plan file across different models of devices is not recommended and is likely to affect performance or even cause errors.
[12/26/2024-17:51:52] [TRT] [I] [MemUsageChange] Init cuDNN: CPU +616, GPU +636, now: CPU 1011, GPU 6738 (MiB)
[12/26/2024-17:51:52] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in engine deserialization: CPU +0, GPU +10, now: CPU 0, GPU 10 (MiB)
[12/26/2024-17:51:52] [TRT] [I] [MemUsageChange] Init cuDNN: CPU +0, GPU +17, now: CPU 1000, GPU 6734 (MiB)
[12/26/2024-17:51:52] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in IExecutionContext creation: CPU +0, GPU +18, now: CPU 0, GPU 28 (MiB)

Found https://ultralytics.com/images/bus.jpg locally at bus.jpg
image 1/1 /home/xliu/yolo_test/bus.jpg: 640x640 4 persons, 1 bus, 36.4ms
Speed: 37.7ms preprocess, 36.4ms inference, 74.0ms postprocess per image at shape (1, 3, 640, 640)

Hi,

Do you mean this log?

WARNING ⚠️ Unable to automatically guess model task, assuming 'task=detect'. Explicitly define task for your model, i.e. 'task=detect', 'segment', 'classify','pose' or 'obb'.

The message looks like a user space harmless warning.
So you might just ignore it.

Thanks.

Thank you for replying, but I am actually mean this log:

$ python3 -c "import torchvision; print(torchvision.__version__)"
/usr/local/lib/python3.8/dist-packages/torchvision/io/image.py:13: UserWarning: Failed to load image Python extension: '/usr/local/lib/python3.8/dist-packages/torchvision/image.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSsb'If you don't plan on using image functionality from `torchvision.io`, you can ignore this warning. Otherwise, there might be something wrong with your environment. Did you have `libjpeg` or `libpng` installed before building `torchvision` from source?
  warn(
0.16.2+c6f3977

Hi,

Based on the log, please try to install libjpeg and libpng to fix the issue.

$ sudo apt install libjpeg-dev libpng-dev

Thanks.

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