Installing torchvison in Jetson AGX Orin

I’v installed PyTorch v1.12.0 successfully on Jetson AGX Orin DevKit and the after verification with torch.cuda.is_available() it turns out that Torch can see and make use of the GPU. Now I’m trying to install torchvision v0.13.0 as mentioned in (pre-built PyTorch pip wheel installers for Python on Jetson)

PyTorch v1.12 - torchvision v0.13.0

All have been installed in a python venv

I have a problem with installing torchvision with :

$ sudo apt-get install libjpeg-dev zlib1g-dev libpython3-dev libavcodec-dev libavformat-dev libswscale-dev

$ git clone --branch <version> https://github.com/pytorch/vision 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 setup.py install --user

I’ve done the first step and cloned the repository and export BUILD_VERSION=0.13.0 but when I’m trying to run the setup file with python3 setup.py install --user it tells me the following:

Building wheel torchvision-0.13.0
PNG found: True
libpng version: 1.6.37
Building torchvision with PNG image support
libpng include path: /usr/include/libpng16
Running build on conda-build: False
Running build on conda: False
JPEG found: True
Building torchvision with JPEG image support
NVJPEG found: False
FFmpeg found: False
video codec found: False
The installed version of ffmpeg is missing the header file 'bsf.h' which is required for GPU video decoding. Please install the latest ffmpeg from conda-forge channel: `conda install -c conda-forge ffmpeg`.
running install
Checking .pth file support in /home/naser/.local/lib/python3.8/site-packages/
/home/naser/torch_yolo/bin/python3 -E -c pass
TEST FAILED: /home/naser/.local/lib/python3.8/site-packages/ does NOT support .pth files
error: bad install directory or PYTHONPATH

You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from.  The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /home/naser/.local/lib/python3.8/site-packages/

and your PYTHONPATH environment variable currently contains:

    ''

Here are some of your options for correcting the problem:

* You can choose a different installation directory, i.e., one that is
  on PYTHONPATH or supports .pth files

* You can add the installation directory to the PYTHONPATH environment
  variable.  (It must then also be on PYTHONPATH whenever you run
  Python and want to use the package(s) you are installing.)

* You can set up the installation directory to support ".pth" files by
  using one of the approaches described here:

  https://setuptools.readthedocs.io/en/latest/easy_install.html#custom-installation-locations


Please make the appropriate changes for your system and try again.

I think the problem is in export BUILD_VERSION=0.13.0 but I can’t figure out what is the problem.

Hi,

Based on the log, there are some missing libraries in your environment.
Could you install the libraries and try it again?

Building torchvision with JPEG image support
NVJPEG found: False
FFmpeg found: False
video codec found: False
The installed version of ffmpeg is missing the header file 'bsf.h' which is required for GPU video decoding. Please install the latest ffmpeg from conda-forge channel: `conda install -c conda-forge ffmpeg`.
running install
...

Thanks.

dear AastaLLL

I’ve installed achiconda3 and created an conda environment, then I followed the steps provided in to install torch and torch vision, however got the following error when I’m trying to run the setup file using the command python3 setup.py install --user:

Traceback (most recent call last):
  File "setup.py", line 14, in <module>
    import torch
  File "/home/naser/archiconda3/envs/torch10/lib/python3.6/site-packages/torch/__init__.py", line 195, in <module>
    _load_global_deps()
  File "/home/naser/archiconda3/envs/torch10/lib/python3.6/site-packages/torch/__init__.py", line 148, in _load_global_deps
    ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL)
  File "/home/naser/archiconda3/envs/torch10/lib/python3.6/ctypes/__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libmpi_cxx.so.20: cannot open shared object file: No such file or directory

I tried to solve the problem by finding the libmpi_cxx.so.20 and install it after searching for it sudo apt install apt-file, but it still didn’t work

When I tried to import torch, I got the same error message

Hi,

Could you also try to import the PyTorch outside of the environment?
Does it work?

Thanks.

It should work if i have installed the PyTorch in the system but i want to isolate it in an environment like conda or python vertualenv.

do you recommend just using the containers provided by NVIDIA?

Hi,

Our container has all the dependencies installed so you don’t need to do it on your own.

Based on the error, please try to install the below libraries to see if it helps

sudo apt-get install libopenblas-base libopenmpi-dev 

Thanks.

1 Like

Thank you @AastaLLL so much every thing is fine now.

After many trials I decided to re-flash the Orin and install every thing again, I’ve installed PyTorch 0.13.0 and torchvision and all other dependencies of my Pipeline.

Good to know this!
Thanks for the feedback.

1 Like

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