Torch and torchvision installation

  • python -m venv ENV
  • source ENV/bin/activate
  • wget -O torch-2.0.0+nv23.05-cp38-cp38-linux_aarch64.whl
  • sudo apt-get install python3-pip libopenblas-base libopenmpi-dev libomp-dev
  • pip3 install Cython
  • pip3 install numpy torch-2.0.0+nv23.05-cp38-cp38-linux_aarch64.whl
  • sudo apt-get install libjpeg-dev zlib1g-dev libpython3-dev libopenblas-dev libavcodec-dev libavformat-dev libswscale-dev
  • git clone --branch v0.15.1 GitHub - pytorch/vision: Datasets, Transforms and Models specific to Computer Vision torchvision
  • cd torchvision
  • export BUILD_VERSION=0.15.1
  • python3 install --user
    When I try to run python3 install --user it show
    Building wheel torchvision-0.15.1
    Compiling extensions with following flags:
    FORCE_CUDA: False
    DEBUG: False
    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
    Building torchvision without NVJPEG image support
    Building torchvision without ffmpeg support
    Building torchvision without video codec support
    running install
    Checking .pth file support in /home/mic-733ao/.local/lib/python3.8/site-packages/
    /home/mic-733ao/data/verilyvision/VV_Por/lpr-exat-exit/ENV/bin/python3 -E -c pass
    TEST FAILED: /home/mic-733ao/.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:
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:
    Please make the appropriate changes for your system and try again.


Checking .pth file support in /home/mic-733ao/.local/lib/python3.8/site-packages/
/home/mic-733ao/data/verilyvision/VV_Por/lpr-exat-exit/ENV/bin/python3 -E -c pass
TEST FAILED: /home/mic-733ao/.local/lib/python3.8/site-packages/ does NOT support .pth files
error: bad install directory or PYTHONPATH

This looks related to the virtual environment.
Could you check if setting up the PYTHONPATH helps?

$ export PYTHONPATH="${PYTHONPATH}:/home/mic-733ao/.local/lib/python3.8/site-packages/"


1 Like

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