NVIDIA nvcomp for CUDA 12

raw JSON →
5.2.0.13 verified Fri May 01 auth: no python

NVIDIA nvcomp is a high-speed lossless compression/decompression library designed for use on NVIDIA GPUs. This package provides the pre-built CUDA 12 binaries (libnvcomp.so) for Python. Version 5.2.0.13 is current. Release cadence is tied to CUDA toolkit releases.

pip install nvidia-libnvcomp-cu12
error OSError: libnvcomp.so: cannot open shared object file: No such file or directory
cause The package installs the .so file, but it may not be on the library search path.
fix
Set LD_LIBRARY_PATH to include the site-packages/nvidia/libnvcomp/cu12 directory, or use os.add_dll_directory on Windows.
error AttributeError: module 'cffi' has no attribute 'FFI'
cause Attempting to use cffi without importing correctly.
fix
Use from cffi import FFI (note: this is a common mistake but actually from cffi import FFI is correct).
error ImportError: libcuda.so.1: cannot open shared object file: No such file or directory
cause The NVIDIA CUDA driver runtime library is not installed or not in the library path.
fix
Install the NVIDIA driver and CUDA toolkit, or if using a container, ensure the base image includes CUDA.
gotcha This package only provides the compiled shared library (libnvcomp.so) for CUDA 12. It does not include Python bindings; you must use ctypes, cffi, or a higher-level library like cuPy or RAPIDS.
fix Install a Python wrapper (e.g., `nvcomp` from NVIDIA or use ctypes directly).
gotcha The library is version-specific to CUDA 12. If you are using a different CUDA version (e.g., 11.x), this package will not work and may cause runtime errors.
fix Use the appropriate `nvidia-libnvcomp-cuX` package for your CUDA version, or install the CUDA 12 toolkit.
deprecated Some older APIs in nvcomp are deprecated in version 5.2.0. In particular, the GDeflate API has been superseded by Bitcomp; old function names still exist but may be removed in a future release.
fix Migrate calls from `nvcompGdeflate*` to `nvcompBitcomp*` functions.

Verify that the nvcomp shared library is accessible and loadable.

import ctypes
import os

# Load the library (adjust path if needed)
lib_path = os.environ.get('NVCOMP_LIB_PATH', 'libnvcomp.so')
try:
    lib = ctypes.CDLL(lib_path)
    print('nvcomp library loaded successfully')
except OSError as e:
    print(f'Failed to load: {e}')