+
Skip to content

ROCm/rocPyDecode

Repository files navigation

MIT licensed

AMD rocPyDecode Logo

Note

The published documentation is available at rocPyDecode in an organized, easy-to-read format, with search and a table of contents. The documentation source files reside in the docs folder of this repository. As with all ROCm projects, the documentation is open source. For more information on contributing to the documentation, see Contribute to ROCm documentation.

rocPyDecode is a Python binding library that connects Python with AMD’s rocDecode and rocJPEG C/C++ APIs, enabling seamless function calls and data exchange between the two languages. It serves as a high-level wrapper, making the video and image decoding capabilities of rocDecode and rocJPEG accessible from Python.

rocPyDecode includes rocPyJpegDecode when the underlying rocJPEG library is available on the system, providing JPEG-specific decoding support through Python. The library supports multi-VCN configurations via batch decoding, making it well-suited for high-throughput and parallelized image and video processing workloads.

Prerequisites

Operating Systems

  • Linux
    • Ubuntu - 22.04 / 24.04

Hardware

Important

gfx908 or higher GPU required

  • Install ROCm 7.0.0 or later with amdgpu-install: Required usecase:rocm

Important

sudo amdgpu-install --usecase=rocm

Compiler

  • AMD Clang++ Version 18.0.0 or later - installed with ROCm

Libraries

  • CMake 3.15 or higher

    sudo apt install cmake
  • rocDecode 1.0.0 or higher

    sudo apt install rocdecode-dev
  • rocJPEG 1.0.0 or higher

    sudo apt install rocjpeg-dev
  • DLPack

    sudo apt install libdlpack-dev
  • Python3 and Python3 PIP

    sudo apt install python3-dev python3-pip
  • PyBind11

    sudo apt install python3-pybind11
  • numpy

     sudo apt install python3-numpy

Note

'numpy' required for the test scripts and samples, not required for the build and install

  • pkg-config

    sudo apt install pkg-config
  • FFmpeg

    sudo apt install libavcodec-dev libavformat-dev libavutil-dev

Important

  • Required compiler support
    • C++17
    • Threads

Note

  • All package installs are shown with the apt package manager. Use the appropriate package manager for your operating system.

Prerequisites setup script

For your convenience, we provide the setup script, rocPyDecode-requirements.py, which installs all required dependencies. Run this script only once on bare metal, if using docker please see below instructions.

python3 rocPyDecode-requirements.py

rocPyDecode install

The installation process uses the following steps:

Important

Use either package install or source install as described below.

Package install

Install rocPyDecode runtime, and test packages.

  • Runtime package - rocpydecode only provides the python bindings for rocDecode
  • Test package - rocpydecode-test provides ctest to verify installation

Ubuntu

sudo apt-get install rocpydecode rocpydecode-test

Important

Python module: To use python module, set PYTHONPATH:

  • export PYTHONPATH=/opt/rocm/lib:$PYTHONPATH

Source install

To build rocPyDecode from source and install, follow the steps below:

  • Clone rocPyDecode source code
git clone https://github.com/ROCm/rocPyDecode.git
  • Build rocPyDecode with the CMake

    • run the requirements script to install all the dependencies required:
    cd rocPyDecode
    python3 rocPyDecode-requirements.py
    • run the below commands to build rocPyDecode:
    mkdir build && cd build
    cmake ../
    make -j8
    sudo make install

Important

  • rocPyDecode will be installed for all Python versions on the system. To install rocPyDecode for a specific Python version, use the cmake -D PYTHON_VERSION_SUGGESTED=version_num directive, where version_num is the target Python version.
make test

Note

To run tests with verbose option, use make test ARGS="-VV". Alternate source install methods

Run CTest

This will run python samples and show pass/fail.

Note

install rocPydecode before running tests

Dependencies:

python3 -m pip install --upgrade pip
python3 -m pip install -i https://test.pypi.org/simple hip-python

Run tests with source

mkdir rocpydecode-test && cd rocpydecode-test
cmake ../rocPyDecode/tests
ctest -VV

Run tests with rocpydecode-test package

Test package will install ctest module to test rocPyDecode. Follow below steps to test package install

mkdir rocpydecode-test && cd rocpydecode-test
cmake /opt/rocm/share/rocpydecode/tests
ctest -VV

Note

Make sure all required libraries are in your PATH

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/rocm/lib
export PYTHONPATH=/opt/rocm/lib:$PYTHONPATH

Run Sample Scripts

  • Sample scripts and instructions to run them can be found here

Documentation

Run the following code to build our documentation locally.

cd docs
pip3 install -r sphinx/requirements.txt
python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en . _build/html

For more information on documentation builds, refer to the Building documentation page.

Tested configurations

  • Linux distribution
    • Ubuntu - 22.04 / 24.04
  • ROCm: rocm-core - 7.0.0+
  • AMD Clang++ - Version 18.0.0+
  • CMake - Version 3.15+
  • rocdecode-dev - 1.0.0+
  • rocjpeg-dev - 1.0.0+
  • libdlpack-dev - 0.6-1
  • python3-pybind11 - 2.9.1-2
  • FFmpeg - 4.4.2 / 6.1.1

About

rocPyDecode is a set of Python bindings to rocDecode C++ library which provides full HW acceleration for video decoding on AMD GPUs.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 15

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载