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

Issues with installing & using PyTorch plugin via pip #424

Closed Renzzauw closed 1 year ago

Renzzauw commented 1 year ago

Hi!

I'm really happy to see you can now install VPF using pip. I wanted to try it out, but I ran into some issues when I tried to follow the documentation.

When I wanted to install the PyTorch plugin, as stated by the documentation, the line pip install src/PytorchNvCodec/ does not appear to work. I get the following error: ERROR: Directory 'src/PytorchNvCodec/' is not installable. Neither 'setup.py' nor 'pyproject.toml' found. Upon changing this to pip install src/PytorchNvCodec/src/ this does seem to run an installation, so perhaps the docs are incorrect here.

I do have no issues with installing the main PyNvCodec module, and I can import it issue-free. However, after successfully running pip install src/PytorchNvCodec/src/, I am not able to import the PytorchNvCodec module. When I try to do so, I get the following error:

Traceback (most recent call last):
  File "/home/ubuntu/vpf_test/test.py", line 2, in <module>
    import PytorchNvCodec
ImportError: libc10.so: cannot open shared object file: No such file or directory

I did follow the docs and have the torch package installed in my venv.

Is this a bug or did I do something wrong while installing? Thanks!

gedoensmax commented 1 year ago

Hi thanks for the issue report! Could you check the pull request ?

Renzzauw commented 1 year ago

Hi @gedoensmax, thanks for checking this out. I've pulled the branch, and I'm not getting any issues anymore when importing the PyNvCodec module. Thanks for resolving this!

I got the following error while trying to run some test code, but I assume this has nothing to do with the module importing issue:

Traceback (most recent call last):
  File "/home/ubuntu/vpf_test/test.py", line 45, in <module>
    success = video_encoder.EncodeSingleSurface(src_surface, enc_frame)
RuntimeError: LoadNvEncApi : Current Driver Version does not support this NvEncodeAPI version, please upgrade driver at /home/ubuntu/VideoProcessingFramework/src/TC/src/NvEncoder.cpp:125

I'm a bit unsure how to fix this issue or what driver version I should get, as it's pointing to one of the source code files. Do you know where/how I can find out what drive version I need?

Anyway, once I fix my driver mismatch issue, I'll test further with the PyTorch plugin to see if I run into any trouble.

gedoensmax commented 1 year ago

Which driver do you have right now ? Usually the latest should do the job.

theHamsta commented 1 year ago

Hi @gedoensmax, thanks for checking this out. I've pulled the branch, and I'm not getting any issues anymore when importing the PyNvCodec module. Thanks for resolving this!

I got the following error while trying to run some test code, but I assume this has nothing to do with the module importing issue:

Traceback (most recent call last):
  File "/home/ubuntu/vpf_test/test.py", line 45, in <module>
    success = video_encoder.EncodeSingleSurface(src_surface, enc_frame)
RuntimeError: LoadNvEncApi : Current Driver Version does not support this NvEncodeAPI version, please upgrade driver at /home/ubuntu/VideoProcessingFramework/src/TC/src/NvEncoder.cpp:125

I'm a bit unsure how to fix this issue or what driver version I should get, as it's pointing to one of the source code files. Do you know where/how I can find out what drive version I need?

Anyway, once I fix my driver mismatch issue, I'll test further with the PyTorch plugin to see if I run into any trouble.

We're now including the headers of Video Codec SDK 12.0 which have a minimal required driver version.

We've introduced a CMake variable https://github.com/NVIDIA/VideoProcessingFramework/blob/6770a888734bf28fa51c72d2d697a1422e6fb77a/src/TC/CMakeLists.txt#L102-L104 if you want to use your own (older) headers that have lower driver requirements. This CMake variable should point to a path that contains the following files https://github.com/NVIDIA/VideoProcessingFramework/tree/master/src/TC/third_party . Each release of the Video Codec SDK comes with an Interface folder that contains those files.

Please see https://scikit-build.readthedocs.io/en/latest/usage.html#environment-variable-configuration on how to specify CMake defines -DTC_VIDEO_CODEC_INTERFACE_DIR=... when using the pip build. The variables can also be edited using cmake-gui on the _skbuild folder created by a pip installation.

Renzzauw commented 1 year ago

I'm currently running Ubuntu 20.04 with CUDA version 11.6 and driver version 510.47.03. Additionally, I was using Video Codec SDK version 11.1.5 headers. These all seemed to work fine previously, but I suppose this is all a bit outdated now after this large update to the repo. I'll experiment with newer versions and the CMake variables!