opencv_contrib: Cuda 10.0 fatal error: dynlink_nvcuvid.h: No such file or directory

System information (version)
  • OpenCV => Master branch
  • Operating System / Platform => Linux 18.04
  • Compiler => GCC 7.3
Detailed description

Trying to compile opencv and getting this error

In file included from /home/achal/achal/tools/opencv/build/modules/cudacodec/opencv_cudacodec_pch_dephelp.cxx:1:0:
/home/achal/achal/tools/opencv_contrib/modules/cudacodec/src/precomp.hpp:60:18: fatal error: dynlink_nvcuvid.h: No such file or directory
         #include <dynlink_nvcuvid.h>
                  ^~~~~~~~~~~~~~~~~~~
compilation terminated.
modules/cudacodec/CMakeFiles/opencv_cudacodec_pch_dephelp.dir/build.make:62: recipe for target 'modules/cudacodec/CMakeFiles/opencv_cudacodec_pch_dephelp.dir/opencv_cudacodec_pch_dephelp.cxx.o' failed

I checked the include directory of cuda 10, there is not dynlink_nvcuvid.h or nvcuvid.h. So may be they moved this code to somewhere.

Steps to reproduce
mkdir build  

cd build  

cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON -DCUDA_ARCH_BIN="3.0 3.5 3.7 5.0 5.2 6.0 6.1" -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -DWITH_CUDA=ON -DWITH_OPENCL=OFF -DWITH_OPENCLAMDBLAS=OFF -DWITH_OPENCLAMDFFT=OFF -DCUDA_NVCC_FLAGS="--expt-relaxed-constexpr" -DOPENCV_ENABLE_NONFREE=ON -DBUILD_opencv_cnn_3dobj=OFF -DBUILD_opencv_dnn=OFF -DBUILD_opencv_dnn_modern=OFF -DBUILD_opencv_cudacodec=ON -DWITH_GTK_2_X=ON ..  

make -j

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 13
  • Comments: 15 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Seems like cuda video decoder is deprecated.

https://docs.nvidia.com/cuda/video-decoder/index.html

That’s why -DBUILD_opencv_cudacodec=OFF fixes the issue. Thanks @alalek !

Try cmake -DBUILD_opencv_cudacodec=OFF .... It is tested with CUDA <= 6.5 only. After that CUDA API is changed for decoding/encoding - updates are not supported yet.

Also try to disable precopmiled headers (it is buggy in some configurations):

cmake -DENABLE_PRECOMPILED_HEADERS=OFF ...

(but this can’t help if file is missing)

Regarding this issue. When compiling with the option WITH_NVCUVID I get:

fatal error: nvcuvid.h: No such file or directory
         #include <nvcuvid.h>
                  ^~~~~~~~~~~

I found out that the NVIDIA Video Decoder (NVCUVID) is deprecated since CUDA 10. One should get the NVIDIA VIDEO CODEC SDK, which is default installed on /opt/nvidia-video-codec.

So it’s needed to modify the FindCUDA.cmake, OpenCVDetectCUDA.cmake or add a new file to find the module and include the path /opt/nvidia-video-codec/include as: /usr/bin/c++ ... -isystem /opt/nvidia-video-codec/include ...

The quickest solution is to add the following flag -DCMAKE_CXX_FLAGS=-isystem\ /opt/nvidia-video-codec/include

Although, I’ve also found that the FindCUDA module has been superseded by first-class support for the CUDA language in CMake

@quanticsolutions : there are two ways to overcome this problem.

  1. just don’t compile opencv_cudacodec, you could disable it via cmake gui or ccmake
  2. As above, install the nvidia Video Codec SDK and try to have a look into the opencv_contrib git repo, in the master branch, in modules/cudacodec, they have already fixed the bug, so a patch is not necessary anymore. Gernerally specking, you need sth like this #if CUDA_VERSION >= 9000 && CUDA_VERSION < 10000 #include <dynlink_nvcuvid.h> #else #include <nvcuvid.h> #endif

@quanticsolutions : there are two ways to overcome this problem.

1. just don't compile opencv_cudacodec, you could disable it via cmake gui or ccmake

2. As above, install the nvidia Video Codec SDK and try to have a look into the opencv_contrib git repo, in the master branch, in modules/cudacodec, they have already fixed the bug, so a patch is not necessary anymore. Gernerally specking, you need sth like this
   #if CUDA_VERSION >= 9000 && CUDA_VERSION < 10000
   #include <dynlink_nvcuvid.h>
   #else
   #include <nvcuvid.h>
   #endif

Thank you! Worked for me using CUDA 10.1 and OpenCV 3.4.8. I had to modify these files:

./opencv/modules/cudacodec/src/cuvid_video_source.hpp
./opencv/modules/cudacodec/src/video_decoder.hpp
./opencv/modules/cudacodec/src/frame_queue.hpp
./opencv/modules/cudacodec/src/video_parser.hpp
./opencv/modules/cudacodec/src/precomp.hpp

Hey guys, I also ran into this problem, this is because of the deprecation for NVCUVID. Instead, NVIDIA provides Video Codec SDK. if you are going to use cuda 10 with opencv 3.4.x, then you need to copy the header and libs from Video Codec SDK into cuda AND change the related opencv header to use nvcuvid.h BUT NOT dynlink_nvcuvid.h. Then you get compling done, but if it can work well, I am not sure.

Cheers.

HZ

doesnt work… I downloaded the codec sdk

I then I actually copied the cuviddec.h and nvcuvid.h files into /usr/local/cuda/include/ and renamed nvcuvid.h to dynlink_nvcuvid.h

recompiled opencv 3.4.3 with -D BUILD_opencv_cudacodec=ON

still same problem with video feeds decoding via CPU with 5fps…

When I use OpenCV 3.2 it works 30+ fps as expected…

this really sucks… because if you read from video cameras via videocapture.read, the yuy2rgb conversion is no longer done via gpu and it drops 1080p framerates from over 30fps down to 5fps… 😦

  1. I tried GStreamer with OpenCV 3.4.3, but still getting 5fps…

  2. I used to get 30fps using OpenCV 3.2.x at 1080p (sounds like it was v4l)

  3. Thanks, I’ll have a look to see if MJPG can be used as per comment.

  4. Because this seemed to be a nvcuvid codec issue… i.e. its bypassing the CUDA codec and using CPU… I could have been wrong, but thats the only thing that changed in building Opencv since the build broke wihtout “-DBUILD_opencv_cudacodec=OFF” but then I got 5fps when not using cudacodec…

FYI - I have full 30fps now working via v4l2 and using V4L2_PIX_FMT_MJPEG going straight ioctl with /dev/video0 access… I will see if I can get it going through opencv…