opencv_contrib: Accuracy cudacodec test fails always with -DWITH_NVCUVID=ON

Accuracy:cudacodec fails always if -DWITH_NVCUVID=ON flag is set for a build, all tests are failed there.

List of failed tests:

[  PASSED  ] 0 tests.
[  FAILED  ] 48 tests, listed below:
[  FAILED  ] CUDA_Codec/CheckSet.Reader/0, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4")
[  FAILED  ] CUDA_Codec/CheckExtraData.Reader/0, where GetParam() = (Quadro P2000, ("highgui/video/big_buck_bunny.mp4", 45))
[  FAILED  ] CUDA_Codec/CheckExtraData.Reader/1, where GetParam() = (Quadro P2000, ("highgui/video/big_buck_bunny.mov", 45))
[  FAILED  ] CUDA_Codec/CheckExtraData.Reader/2, where GetParam() = (Quadro P2000, ("highgui/video/big_buck_bunny.mjpg.avi", 0))
[  FAILED  ] CUDA_Codec/CheckKeyFrame.Reader/0, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4")
[  FAILED  ] CUDA_Codec/CheckKeyFrame.Reader/1, where GetParam() = (Quadro P2000, "cv/video/768x576.avi")
[  FAILED  ] CUDA_Codec/CheckKeyFrame.Reader/2, where GetParam() = (Quadro P2000, "cv/video/1920x1080.avi")
[  FAILED  ] CUDA_Codec/CheckKeyFrame.Reader/3, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.avi")
[  FAILED  ] CUDA_Codec/CheckKeyFrame.Reader/4, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.h264")
[  FAILED  ] CUDA_Codec/CheckKeyFrame.Reader/5, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.h265")
[  FAILED  ] CUDA_Codec/CheckKeyFrame.Reader/6, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mpg")
[  FAILED  ] CUDA_Codec/CheckKeyFrame.Reader/7, where GetParam() = (Quadro P2000, "highgui/video/sample_322x242_15frames.yuv420p.libvpx-vp9.mp4")
[  FAILED  ] CUDA_Codec/CheckKeyFrame.Reader/8, where GetParam() = (Quadro P2000, "highgui/video/sample_322x242_15frames.yuv420p.libaom-av1.mp4")
[  FAILED  ] CUDA_Codec/CheckKeyFrame.Reader/9, where GetParam() = (Quadro P2000, "cv/tracking/faceocc2/data/faceocc2.webm")
[  FAILED  ] CUDA_Codec/Scaling.Reader/0, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4", [1 x 1], [1 x 1 from (0, 0)], [1 x 1 from (0, 0)])
[  FAILED  ] CUDA_Codec/Scaling.Reader/1, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4", [1 x 1], [1 x 1 from (0, 0)], [0.6 x 0.7 from (0.2, 0.3)])
[  FAILED  ] CUDA_Codec/Scaling.Reader/2, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4", [1 x 1], [0.5 x 0.5 from (0.25, 0.25)], [1 x 1 from (0, 0)])
[  FAILED  ] CUDA_Codec/Scaling.Reader/3, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4", [1 x 1], [0.5 x 0.5 from (0.25, 0.25)], [0.6 x 0.7 from (0.2, 0.3)])
[  FAILED  ] CUDA_Codec/Scaling.Reader/4, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4", [0.8 x 0.9], [1 x 1 from (0, 0)], [1 x 1 from (0, 0)])
[  FAILED  ] CUDA_Codec/Scaling.Reader/5, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4", [0.8 x 0.9], [1 x 1 from (0, 0)], [0.6 x 0.7 from (0.2, 0.3)])
[  FAILED  ] CUDA_Codec/Scaling.Reader/6, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4", [0.8 x 0.9], [0.5 x 0.5 from (0.25, 0.25)], [1 x 1 from (0, 0)])
[  FAILED  ] CUDA_Codec/Scaling.Reader/7, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4", [0.8 x 0.9], [0.5 x 0.5 from (0.25, 0.25)], [0.6 x 0.7 from (0.2, 0.3)])
[  FAILED  ] CUDA_Codec/Scaling.Reader/8, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4", [2.3 x 1.8], [1 x 1 from (0, 0)], [1 x 1 from (0, 0)])
[  FAILED  ] CUDA_Codec/Scaling.Reader/9, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4", [2.3 x 1.8], [1 x 1 from (0, 0)], [0.6 x 0.7 from (0.2, 0.3)])
[  FAILED  ] CUDA_Codec/Scaling.Reader/10, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4", [2.3 x 1.8], [0.5 x 0.5 from (0.25, 0.25)], [1 x 1 from (0, 0)])
[  FAILED  ] CUDA_Codec/Scaling.Reader/11, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4", [2.3 x 1.8], [0.5 x 0.5 from (0.25, 0.25)], [0.6 x 0.7 from (0.2, 0.3)])
[  FAILED  ] CUDA_Codec/Video.Reader/0, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4")
[  FAILED  ] CUDA_Codec/Video.Reader/1, where GetParam() = (Quadro P2000, "cv/video/768x576.avi")
[  FAILED  ] CUDA_Codec/Video.Reader/2, where GetParam() = (Quadro P2000, "cv/video/1920x1080.avi")
[  FAILED  ] CUDA_Codec/Video.Reader/3, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.avi")
[  FAILED  ] CUDA_Codec/Video.Reader/4, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.h264")
[  FAILED  ] CUDA_Codec/Video.Reader/5, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.h265")
[  FAILED  ] CUDA_Codec/Video.Reader/6, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mpg")
[  FAILED  ] CUDA_Codec/Video.Reader/7, where GetParam() = (Quadro P2000, "highgui/video/sample_322x242_15frames.yuv420p.libvpx-vp9.mp4")
[  FAILED  ] CUDA_Codec/Video.Reader/8, where GetParam() = (Quadro P2000, "highgui/video/sample_322x242_15frames.yuv420p.libaom-av1.mp4")
[  FAILED  ] CUDA_Codec/Video.Reader/9, where GetParam() = (Quadro P2000, "cv/tracking/faceocc2/data/faceocc2.webm")
[  FAILED  ] CUDA_Codec/VideoReadRaw.Reader/0, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.h264")
[  FAILED  ] CUDA_Codec/VideoReadRaw.Reader/1, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.h265")
[  FAILED  ] CUDA_Codec/CheckParams.Reader/0, where GetParam() = Quadro P2000
[  FAILED  ] CUDA_Codec/CheckDecodeSurfaces.Reader/0, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4")
[  FAILED  ] CUDA_Codec/CheckInitParams.Reader/0, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4", true, true, true)
[  FAILED  ] CUDA_Codec/CheckInitParams.Reader/1, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4", true, true, false)
[  FAILED  ] CUDA_Codec/CheckInitParams.Reader/2, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4", true, false, true)
[  FAILED  ] CUDA_Codec/CheckInitParams.Reader/3, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4", true, false, false)
[  FAILED  ] CUDA_Codec/CheckInitParams.Reader/4, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4", false, true, true)
[  FAILED  ] CUDA_Codec/CheckInitParams.Reader/5, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4", false, true, false)
[  FAILED  ] CUDA_Codec/CheckInitParams.Reader/6, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4", false, false, true)
[  FAILED  ] CUDA_Codec/CheckInitParams.Reader/7, where GetParam() = (Quadro P2000, "highgui/video/big_buck_bunny.mp4", false, false, false)

An example of a failed test:

[ RUN      ] CUDA_Codec/Video.Reader/9, where GetParam() = (Quadro P2000, "cv/tracking/faceocc2/data/faceocc2.webm")
unknown file: Failure
C++ exception with description "OpenCV(4.6.0-dev) /home/ci/opencv_contrib/modules/cudacodec/src/video_parser.cpp:63: error: (-217:Gpu API call) Unknown error code [Code = 1892716896] in function 'VideoParser'
" thrown in the test body.
[  FAILED  ] CUDA_Codec/Video.Reader/9, where GetParam() = (Quadro P2000, "cv/tracking/faceocc2/data/faceocc2.webm") (85 ms)
System information (version)
  • OpenCV version: 4.6.0
  • Operating System / Platform: Ubuntu 20.04
  • Compiler & compiler version: GCC 9.4.0
  • GPU: Quadro P2000

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (19 by maintainers)

Most upvoted comments

@cudawarped, thank you for your support!

Finally, I made it to work. I re-installed all nvidia components and just did not install NVIDIA Video codec SDK over CUDA, but copied headers from Video_Codec_SDK_11.1.5/Interfaces folder to /usr/local/cuda/include.

Firstly, NVCUVID couldn’t be detected and I defined certain libraries for it and CUDA using following flags -DCUDA_CUDA_LIBRARY=/lib/x86_64-linux-gnu/libcuda.so.1 -DCUDA_nvcuvid_LIBRARY=/lib/x86_64-linux-gnu/libnvcuvid.so.1. So, in this case NVCUVID can be detected and OpenCV builds successfully.

Tests started to run successfully also, but some of them failed anyway:

[  PASSED  ] 44 tests.
[  FAILED  ] 4 tests, listed below:
[  FAILED  ] CUDA_Codec/CheckKeyFrame.Reader/8, where GetParam() = (Quadro P2000, "highgui/video/sample_322x242_15frames.yuv420p.libaom-av1.mp4")
[  FAILED  ] CUDA_Codec/CheckKeyFrame.Reader/9, where GetParam() = (Quadro P2000, "cv/tracking/faceocc2/data/faceocc2.webm")
[  FAILED  ] CUDA_Codec/Video.Reader/8, where GetParam() = (Quadro P2000, "highgui/video/sample_322x242_15frames.yuv420p.libaom-av1.mp4")
[  FAILED  ] CUDA_Codec/Video.Reader/9, where GetParam() = (Quadro P2000, "cv/tracking/faceocc2/data/faceocc2.webm")

It happened in case of hardware decoding, example:

[ RUN      ] CUDA_Codec/Video.Reader/8, where GetParam() = (Quadro P2000, "highgui/video/sample_322x242_15frames.yuv420p.libaom-av1.mp4")
unknown file: Failure
C++ exception with description "OpenCV(4.6.0-dev) /home/ci/opencv_contrib/modules/cudacodec/src/video_reader.cpp:184: error: (-2:Unspecified error) Parsing/Decoding video source failed, check GPU memory is available and GPU supports hardware decoding. in function 'internalGrab'
" thrown in the test body.
[  FAILED  ] CUDA_Codec/Video.Reader/8, where GetParam() = (Quadro P2000, "highgui/video/sample_322x242_15frames.yuv420p.libaom-av1.mp4") (69 ms)

Some updates for this issue how to build OpenCV with NVCUVID support inside nvidia-docker.

  • To make NVCUVID work need to install Nvidia driver, CUDA, copy headers from Video_Codec_SDK_11.1.5/Interfaces to /usr/local/cuda/include
  • To use it inside nvidia-docker container need to forward certain libs (it should be by a driver, apt instal libnvidia-encode-515 inside container won’t help) and cuda itself inside:
    • -v /lib/x86_64-linux-gnu/libnvidia-encode.so.1:/lib/x86_64-linux-gnu/libnvidia-encode.so.1
    • -v /lib/x86_64-linux-gnu/libnvcuvid.so.1:/lib/x86_64-linux-gnu/libnvcuvid.so.1
    • -v /usr/local/cuda:/usr/local/cuda
  • Also add cmake flags defining these libs -DCUDA_CUDA_LIBRARY=/lib/x86_64-linux-gnu/libcuda.so.1 -DCUDA_nvcuvid_LIBRARY=/lib/x86_64-linux-gnu/libnvcuvid.so.1

I’m closing this issue, because the error has disappeared and new failures do not relate to the main issue. @cudawarped thank you!

AV1 is only supported on 5th gen NVDEC, P2000 is 3rd gen and not supported but this should get picked up here. My guess is that check needs to be made earlier using FFmpeg’s provided codec (if its supported by FFmpeg) as the parser is failing to create the decoder. Looks like a bug in so much as it should throw a more informative exception, I’ll test on older hardware and fix when I have chance.

Strangely VP8 is also not supported on your P2000.

@cudawarped, the only one difference can be on my side, I run it inside nvidia-docker, maybe some issues inside a container. I will try one more iteration today and provide a feedback.

The stubs should allow you to link against them then use the driver lib, that’s there purpose, maybe the driver lib can’t be found or doesn’t exist for some reason.

I would try just passing in the location of the driver lib e.g.

-DCUDA_nvcuvid_LIBRARY=/lib/x86_64-linux-gnu/libnvcuvid.so.1

Is it possible that you have copied the stub (libnvcuvid.so) into your cuda install and are incorrectly linking against that as discussed in https://github.com/opencv/opencv_contrib/issues/3359.

Does

ldd bin/opencv_test_cudacodec | grep libnvcuvid

give you something similar to

libnvcuvid.so.1 => /usr/local/cuda-11.3/lib64/libnvcuvid.so.1 (0x00007f88a8b72000)

instead of

libnvcuvid.so.1 => /lib/x86_64-linux-gnu/libnvcuvid.so.1 (0x00007f2fcb831000)

If so, can you remove the stub library (libnvcuvid.so) from your cuda installation and try building with either

-DCUDA_nvcuvid_LIBRARY=Video_Codec_SDK_11.1.5/Lib/linux/stubs/x86_64/libnvcuvid.so

or

-DCMAKE_PREFIX_PATH=Video_Codec_SDK_11.1.5/Lib/linux/stubs/x86_64/