A nvImageCodec library of GPU- and CPU- accelerated codecs featuring a unified interface
APACHE-2.0 License
The nvImageCodec is an open-source library of accelerated codecs with unified interface. It is designed as a framework for extension modules which delivers codec plugins.
This nvImageCodec release includes the following key features:
Currently there are following native codec extensions:
nvjpeg_ext
nvjpeg2k_ext
nvbmp_ext (as an example extension module)
nvpnm_ext (as an example extension module)
Additionally as a fallback there are following 3rd party codec extensions:
libturbo-jpeg_ext
libtiff_ext
opencv_ext
This section describes the recommended dependencies to use nvImageCodec.
You can download and install the appropriate built binary packages from the nvImageCodec Developer Page or install nvImageCodec Python from PyPI as it is described below.
pip install nvidia-nvimgcodec-cu11
pip install nvidia-nvimgcodec-cu12
If you do not have CUDA Toolkit installed, or you would like install nvJPEG library independently, you can use the instructions described below.
Install the nvidia-pyindex module
pip install nvidia-pyindex
Install nvJPEG for CUDA 11.x
pip install nvidia-nvjpeg-cu11
Install nvJPEG for CUDA 12.x
pip install nvidia-nvjpeg-cu12
nvJPEG2000 library can be installed in the system, or installed as a Python package. For the latter, follow the instructions below.
Install nvJPEG2000 for CUDA 11.x
pip install nvidia-nvjpeg2k-cu11
Install nvJPEG2000 for CUDA 12.x
pip install nvidia-nvjpeg2k-cu12
Install nvJPEG2000 for CUDA 12.x on Tegra platforms
pip install nvidia-nvjpeg2k-tegra-cu12
Please see also nvJPEG2000 installation documentation for more information
NVIDIA nvImageCodec Documentation
Please see also Dockerfiles.
git lfs clone https://github.com/NVIDIA/nvImageCodec.git
cd nvimagecodec
git submodule update --init --recursive --depth 1
mkdir build
cd build
export CUDACXX=nvcc
cmake .. -DCMAKE_BUILD_TYPE=Release
make
To build CV-CUDA samples, additionally CV-CUDA has to be installed and CVCUDA_DIR and NVCV_TYPES_DIR need to point folders with *-config.cmake files. Apart of that, BUILD_CVCUDA_SAMPLES variable must be set to ON.
Open Developer Command Prompt for VS 2022
git lfs clone https://github.com/NVIDIA/nvImageCodec.git
cd nvimagecodec
git submodule update --init --recursive --depth 1
.\externa\build_deps.bat
.\docker\build_helper.bat .\build 12
After succesfully built project, execute below commands.
cd build
cmake --build . --target wheel
From a successfully built project, installers can be generated using cpack:
cd build
cpack --config CPackConfig.cmake -DCMAKE_BUILD_TYPE=Release
This will generate in build directory *.zip or *tar.xz files
tar -xvf nvimgcodec-0.3.0.0-cuda12-x86_64-linux-lib.tar.gz -C /opt/nvidia/
sudo apt-get install -y ./nvimgcodec-0.3.0.0-cuda12-x86_64-linux-lib.deb
pip install nvidia_nvimgcodec_cu12-0.3.0-py3-none-manylinux2014_x86_64.whl
cd build
cmake --install . --config Release --prefix /opt/nvidia/nvimgcodec_<major_cuda_ver>
After execution there should be:
Add directory with libnvimgcodec.so to LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/opt/nvidia/nvimgcodec_cuda<major_cuda_ver>/lib64:$LD_LIBRARY_PATH
Open Developer Command Prompt for VS 2022
cd build
cmake --install . --config Release --prefix "c:\Program Files\nvimgcodec_cuda<major_cuda_ver>"
After execution there should be:
Add directory with nvimgcodec_0.dll to PATH
Run CTest to execute L0 and L1 tests
cd build
cmake --install . --config Release --prefix bin
ctest -C Release
Run sample transcoder app tests
cd build
cmake --install . --config Release --prefix bin
cd bin/test
LD_LIBRARY_PATH=$PWD/../lib64 pytest -v test_transcode.py
Run Python API tests
First install python wheel. You would also need to have installed all Python tests dependencies (see Dockerfiles).
pip install nvidia_nvimgcodec_cu12-0.3.0.x-py3-none-manylinux2014_x86_64.whl
Run tests
cd tests
pytest -v ./python
To use nvimagecodec as a dependency in your CMake project, use:
list(APPEND CMAKE_PREFIX_PATH "/opt/nvidia/nvimgcodec_cuda<major_cuda_ver>/") # or the prefix where the package was installed if custom
find_package(nvimgcodec CONFIG REQUIRED)
# Mostly for showing some of the variables defined
message(STATUS "nvimgcodec_FOUND=${nvimgcodec_FOUND}")
message(STATUS "nvimgcodec_INCLUDE_DIR=${nvimgcodec_INCLUDE_DIR}")
message(STATUS "nvimgcodec_LIB_DIR=${nvimgcodec_LIB_DIR}")
message(STATUS "nvimgcodec_BIN_DIR=${nvimgcodec_BIN_DIR}")
message(STATUS "nvimgcodec_LIB=${nvimgcodec_LIB}")
message(STATUS "nvimgcodec_EXTENSIONS_DIR=${nvimgcodec_EXTENSIONS_DIR}")
message(STATUS "nvimgcodec_VERSION=${nvimgcodec_VERSION}")
target_include_directories(<your-target> PUBLIC ${nvimgcodec_INCLUDE_DIR})
target_link_directories(<your-target> PUBLIC ${nvimgcodec_LIB_DIR})
target_link_libraries(<your-target> PUBLIC ${nvimgcodec_LIB})