NVIDIA / VideoProcessingFramework

Set of Python bindings to C++ libraries which provides full HW acceleration for video decoding, encoding and GPU-accelerated color space and pixel format conversions
Apache License 2.0
1.32k stars 233 forks source link

Run VPF without CUDA Toolkit? #532

Open mark-selyaeff opened 1 year ago

mark-selyaeff commented 1 year ago

I am trying to build a docker image with VPF using multiple stages. Firstly I use offical nvidia/cuda docker image to build VPF and other GPU-dependent packages, then I copy Python environment with installed packages over to ubuntu20.04 in order to reduce the size of the docker image.

FROM nvidia/cuda:11.4.3-cudnn8-devel-ubuntu20.04

# after creating an env, installing needed packages and updating PATH
RUN pip install git+https://github.com/NVIDIA/VideoProcessingFramework

FROM ubuntu:20.04
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility,video

RUN /testenv/bin/python -c 'import PyNvCodec; PyNvCodec.GetNumGpus()'

VPF builds successfully during first stage, however a simple test run /testenv/bin/python -c 'import PyNvCodec; PyNvCodec.GetNumGpus()' raises the following error:

Traceback (most recent call last):
  File "/testenv/lib/python/site-packages/PyNvCodec/__init__.py", line 17, in <module>
    from ._PyNvCodec import *  # noqa
ImportError: libnppig.so.11: cannot open shared object file: No such file or directory

Could I run VPF without CUDA Toolkit being installed? If I stick to cuda image and don't use plain ubuntu:20.04 the code runs fine without errors.

RomanArzumanyan commented 1 year ago

Hi @mark-selyaeff

There's not enough info to answer your question. I don't know what packages are installed in plain ubuntu:20.04.

ImportError: libnppig.so.11: cannot open shared object file: No such file or directory

This error tells you that VPF libraries were linked against various NV libraries like libcuda.so, libnppig.so, etc. and hence these libraries are required to run VPF.

Unless you have them in your LD_LIBRARY_PATH there's no chance VPF could run for obvious reasons.

mark-selyaeff commented 1 year ago

Using ldd I found and copied over 6 .so files from /usr/local/cuda to ubuntu:20.04 which had no signs of CUDA at all, and now all seems to be working without errors. Is there a way to do that automatically, i.e. pack all needed libraries into a standalone distribution?

RomanArzumanyan commented 1 year ago

Hi @mark-selyaeff

This approach isn't sustainable, you need to install GPU driver on your Ubuntu machine at least. Most probably it's already installed somehow, otherwise CUDA and NPP libraries won't be able to communicate with GPU.