Installation and Usage Description
Before calling PyTorch image operator interfaces, configure the PyTorch and TorchVision environments and apply the required patch file.
Installing Conda and Related Dependencies
- Download the installation script Miniconda3-py312_25.1.1-2-Linux-aarch64.sh.
- Execute the script and press Enter or type yes as prompted.
1 2
bash Miniconda3-py312_25.1.1-2-Linux-aarch64.sh source /root/miniconda3/bin/activate
- Enter the conda environment.
conda activate base
- Install the dependencies.
1 2 3 4 5
conda install cmake ninja numpy pyyaml typing_extensions pillow fsspec jinja2 networkx sympy filelock ffmpeg # Conda cannot install complete GCC and g++, and GCC libraries in the system environment are required. Therefore, the GCC version and g++ major version installed via Conda must be the same as those in the system environment. # For example, you can run the gcc -V command to check the version. If the GCC version is 12, run the following commands: conda install -c conda-forge gcc=12 gxx=12 pip install av==11.0.0 pytest
- Configure the environment variable.
1export LD_LIBRARY_PATH=/root/miniconda3/lib:${LD_LIBRARY_PATH}
Installing PyTorch 2.4.1
PyTorch dependencies include Python, pip, CMake, and other libraries. Before the installation, ensure that the dependencies have been installed.
- Download the PyTorch source code pytorch-v2.4.1.tar.gz.
- Perform compilation and installation.
- Open the Python terminal and enter the following code to check whether PyTorch is installed: Note: Do not run the commands in the pytorch-v2.4.1 source code path. Use another path instead.
1 2
import torch print(torch.__version__)
If the PyTorch version is displayed, PyTorch has been installed.
Installing TorchVision
Before the installation, ensure that PyTorch has been installed.
- Download the TorchVision source code v0.20.0.zip.
- Perform compilation and installation.
1 2
unzip vision-0.20.0.zip && cd vision-0.20.0 && git init && git add . && git commit -m "init" python setup.py install
- Open the Python terminal and enter the following code to check whether TorchVision is installed: Note: Do not run the commands in the vision-0.20.0 source code path. Use another path instead.
1 2
import torchvision print(torchvision.__version__)
If the TorchVision version is displayed, TorchVision has been installed.
Using the PyTorch Image Operator
- Decompress the KPCV software package BoostKit-kp_cv_***.zip to obtain kpt-2.4.1.patch, kpt.patch, and vision-0.20.0.patch.
- Apply the kpt-2.4.1.patch file in the PyTorch source code directory. This patch is required for optimizing the resize function.
1 2
git apply kpt-2.4.1.patch python setup.py install
- Apply patch files in the TorchVision source code directory.
- Apply the kpt.patch file to optimize the normalize and permute functions.
1 2
git apply kpt.patch python setup.py install
- Apply the vision-0.20.0.patch file to optimize the crop and write_video functions.
1 2
git apply vision-0.20.0.patch python setup.py install
After the patch is applied, the PyTorch image operator can be used.
- Apply the kpt.patch file to optimize the normalize and permute functions.
Troubleshooting
- Problem 1: During the installation, a message is displayed indicating that the immintrin.h header file cannot be found.
Solution: Install python-devel.
- Problem 2: "'utf-8' codec can't decode byte 0xe0 in position 5560: invalid continuation byte" is displayed during the installation.

- Problem 3: "undefined reference to `__cxa_thread_atexit_impl@GLIBC_2.18'" is displayed during PyTorch compilation.

Solution:
export CC=/usr/bin/gcc export CXX=/usr/bin/g++
Parent topic: PyTorch Image Operators

