Error: (-213:The function/feature is not implemented)

I am trying to run a sample in the openCV git. I’m not the first person to encounter the issue.

The author closed the issue:

I think I found the issue, I set -D WITH_NVCUVID=ON but finally not build with nvcvid NVIDIA CUDA: YES (ver 10.2, CUFFT CUBLAS)
I don’t know why this setting not work…and no error when building.

Unfortunately I can’t find a solution to the problem. I am using CUDA without any issues in other implementations. I also use the -DWITH_CUDA=ON argument and see the NVIDIA CUDA: YES (ver 10.1, CUFFT CUBLAS).

What am I missing? How can I convince openCV to use CUDA? Or isn’t that the problem?

Error message:

terminate called after throwing an instance of ‘cv::Exception’
what(): OpenCV(4.5.2-dev) /home/user/openCV2/opencv-master/modules/core/include/opencv2/core/private.cuda.hpp:112: error: (-213:The function/feature is not implemented) The called functionality is disabled for current build or platform in function ‘throw_no_cuda’

1 Like

Is cudacodec shown as to be built

To be built: aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec

in your cmake output?

If not you may not have included the Nvidia Video Codec SDK correctly. Are you on windows or linux?

This is the output. I see a lot of CUDA.

– OpenCV modules:
– To be built: aruco barcode bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
– Disabled: world
– Disabled by dependency: -
– Unavailable: alphamat cvv hdf java julia matlab ovis python2 sfm viz
– Applications: tests perf_tests apps
– Documentation: NO
– Non-free algorithms: NO

Sorry I should have asked you to confirm whether NVCUVID is shown in the Nvidia CUDA output as below?

NVIDIA CUDA: YES (ver 11.1, CUFFT CUBLAS NVCUVID FAST_MATH)

Did you download and install the Nvidia Video Codec SDK?

Yes, I already mentioned the output above:
NVIDIA CUDA: YES (ver 10.1, CUFFT CUBLAS) .

I can’t remember downloading the Nvidia Video Codec SDK. Is that necessary?

It doesn’t show NVCUVID.

Yes if you want to decode video using cudacodec.

Okay so hold up - I went here back in the day and choose the left - so ffmpeg.

Do I NEED the application for developers?

You need to tick the box under, for application developers and download the SDK. Which OS are you on? In windows you can simply copy the libs and headers into the cuda directory to install on linux from memory you have to sim link to the stubs.

First off, thanks a ton for your help cudawarped!

Unfortunately, now I’m having trouble installing the SDK. I followed the readme, but something seems to be missing. I’ve solved a few issues by modifying the cmake command.

Trying to build NVIDIA VIDEO CODEC SDK:
$ cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs \
-DCUDA_CUDA_LIBRARY=/usr/local/cuda/lib64/stubs/libcuda.so ..

But I can’t get past the following error message.
Error when installing NVIDIA VIDEO CODEC SDK:

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs -DCUDA_CUDA_LIBRARY=/usr/local/cuda/lib64/stubs/libcuda.so ..
CUDA_CUDA_LIBRARY: /usr/local/cuda/lib64/stubs/libcuda.so
CUDA_TOOLKIT_ROOT_DIR: /usr
-- Attempting auto locate Vulkan using CMake......
VULKAN_PATH: /usr/include
VULKAN_SDK: 
VULKAN_LIB_DIR: 
VULKAN_HDR_DIR: 
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
NVENCODEAPI_LIB
    linked by target "AppEncGL" in directory /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/AppEncode/AppEncGL
    linked by target "AppEncCuda" in directory /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/AppEncode/AppEncCuda
    linked by target "AppEncDec" in directory /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/AppEncode/AppEncDec
    linked by target "AppEncLowLatency" in directory /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/AppEncode/AppEncLowLatency
    linked by target "AppEncME" in directory /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/AppEncode/AppEncME
    linked by target "AppEncPerf" in directory /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/AppEncode/AppEncPerf
    linked by target "AppEncQual" in directory /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/AppEncode/AppEncQual
    linked by target "AppMotionEstimationVkCuda" in directory /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/AppEncode/AppMotionEstimationVkCuda
    linked by target "AppTrans" in directory /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/AppTranscode/AppTrans
    linked by target "AppTransOneToN" in directory /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/AppTranscode/AppTransOneToN
    linked by target "AppTransPerf" in directory /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/AppTranscode/AppTransPerf
    linked by target "AppDec" in directory /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/AppDecode/AppDec
    linked by target "AppDecGL" in directory /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/AppDecode/AppDecGL
    linked by target "AppDecImageProvider" in directory /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/AppDecode/AppDecImageProvider
    linked by target "AppDecLowLatency" in directory /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/AppDecode/AppDecLowLatency
    linked by target "AppDecMem" in directory /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/AppDecode/AppDecMem
    linked by target "AppDecMultiFiles" in directory /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/AppDecode/AppDecMultiFiles
    linked by target "AppDecMultiInput" in directory /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/AppDecode/AppDecMultiInput
    linked by target "AppDecPerf" in directory /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/AppDecode/AppDecPerf

-- Configuring incomplete, errors occurred!
See also "/home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/build/CMakeFiles/CMakeOutput.log".
See also "/home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/build/CMakeFiles/CMakeError.log".

CMakeError.log

Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_cd551/fast && /usr/bin/make -f CMakeFiles/cmTC_cd551.dir/build.make CMakeFiles/cmTC_cd551.dir/build
make[1]: Entering directory '/home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_cd551.dir/src.c.o
/usr/bin/cc   -fPIC -DCMAKE_HAVE_LIBC_PTHREAD   -o CMakeFiles/cmTC_cd551.dir/src.c.o   -c /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/build/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_cd551
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_cd551.dir/link.txt --verbose=1
/usr/bin/cc -fPIC -DCMAKE_HAVE_LIBC_PTHREAD    CMakeFiles/cmTC_cd551.dir/src.c.o  -o cmTC_cd551 
/usr/bin/ld: CMakeFiles/cmTC_cd551.dir/src.c.o: in function `main':
src.c:(.text+0x46): undefined reference to `pthread_create'
/usr/bin/ld: src.c:(.text+0x52): undefined reference to `pthread_detach'
/usr/bin/ld: src.c:(.text+0x63): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_cd551.dir/build.make:87: cmTC_cd551] Error 1
make[1]: Leaving directory '/home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_cd551/fast] Error 2


Source file was:
#include <pthread.h>

void* test_func(void* data)
{
  return data;
}

int main(void)
{
  pthread_t thread;
  pthread_create(&thread, NULL, test_func, NULL);
  pthread_detach(thread);
  pthread_join(thread, NULL);
  pthread_atfork(NULL, NULL, NULL);
  pthread_exit(NULL);

  return 0;
}

Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_0faa4/fast && /usr/bin/make -f CMakeFiles/cmTC_0faa4.dir/build.make CMakeFiles/cmTC_0faa4.dir/build
make[1]: Entering directory '/home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_0faa4.dir/CheckFunctionExists.c.o
/usr/bin/cc   -fPIC -DCHECK_FUNCTION_EXISTS=pthread_create   -o CMakeFiles/cmTC_0faa4.dir/CheckFunctionExists.c.o   -c /usr/share/cmake-3.16/Modules/CheckFunctionExists.c
Linking C executable cmTC_0faa4
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_0faa4.dir/link.txt --verbose=1
/usr/bin/cc -fPIC -DCHECK_FUNCTION_EXISTS=pthread_create    CMakeFiles/cmTC_0faa4.dir/CheckFunctionExists.c.o  -o cmTC_0faa4  -lpthreads 
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_0faa4.dir/build.make:87: cmTC_0faa4] Error 1
make[1]: Leaving directory '/home/user/Downloads/Video_Codec_SDK_11.0.10/Samples/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_0faa4/fast] Error 2

The only CUVID I could find while building OpenCV is WITH_NVCUVID. So I tried adding that to the cmake command as well. No luck.

I built openCV as follows:
cmake \
-DWITH_CUDA=ON \
-DBUILD_CUDA_STUBS=ON \
-DWITH_NVCUVID=ON \
-DWITH_OPENGL=ON \
-DWITH_QT=ON \
-DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-master/modules \
-DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs \
-DCMAKE_C_COMPILER=$(which gcc-8) \
-DCMAKE_CXX_COMPILER=$(which g++-8) \
../opencv-master

The configuration result is:

-- Detected processor: x86_64
-- Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "2.7")
-- Looking for ccache - not found
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found suitable version "1.2.11", minimum required is "1.2.3") 
Cleaning INTERNAL cached variable: WEBP_LIBRARY
Cleaning INTERNAL cached variable: WEBP_INCLUDE_DIR
-- Could NOT find OpenJPEG (minimal suitable version: 2.0, recommended version >= 2.3.1). OpenJPEG will be built from sources
-- OpenJPEG: VERSION = 2.4.0, BUILD = opencv-4.5.2-dev-openjp2-2.4.0
-- OpenJPEG libraries will be built from sources: libopenjp2 (version "2.4.0")
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
-- Found OpenEXR: /usr/lib/x86_64-linux-gnu/libIlmImf.so
CMake Warning (dev) at /usr/share/cmake-3.16/Modules/FindOpenGL.cmake:275 (message):
  Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
  available.  Run "cmake --help-policy CMP0072" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  FindOpenGL found both a legacy GL library:

    OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so

  and GLVND libraries for OpenGL and GLX:

    OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
    OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so

  OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
  compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
  cmake/OpenCVFindLibsGUI.cmake:76 (find_package)
  CMakeLists.txt:717 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- libva: missing va.h header (VA_INCLUDE_DIR)
-- found Intel IPP (ICV version): 2020.0.0 [2020.0.0 Gold]
-- at: /home/user/Downloads/openCV2/build/3rdparty/ippicv/ippicv_lnx/icv
-- found Intel IPP Integration Wrappers sources: 2020.0.0
-- at: /home/user/Downloads/openCV2/build/3rdparty/ippicv/ippicv_lnx/iw
-- Could NOT find CUDNN (missing: CUDNN_LIBRARY CUDNN_INCLUDE_DIR) (Required is at least version "7.5")
-- CUDA detected: 10.1
-- CUDA: Using CUDA_ARCH_BIN=3.0;3.5;3.7;5.0;5.2;6.0;6.1;7.0;7.5
-- CUDA NVCC target flags: -gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_52,code=sm_52;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-D_FORCE_INLINES
-- Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
-- Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
-- Could NOT find Atlas (missing: Atlas_CLAPACK_INCLUDE_DIR) 
-- A library with LAPACK API found.
-- Could NOT find JNI (missing: JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) 
-- Found VTK 9.0.1
-- OpenCV Python: during development append to PYTHONPATH: /home/user/Downloads/openCV2/build/python_loader
-- Module opencv_alphamat disabled because the following dependencies are not found: Eigen
-- freetype2:   YES (ver 23.1.17)
-- harfbuzz:    YES (ver 2.6.4)
-- Could NOT find HDF5 (missing: HDF5_LIBRARIES HDF5_INCLUDE_DIRS) (found version "")
-- Julia not found. Not compiling Julia Bindings. 
-- Module opencv_ovis disabled because OGRE3D was not found
-- No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
-- Failed to find installed gflags CMake configuration, searching for gflags build directories exported with CMake.
-- Failed to find gflags - Failed to find an installed/exported CMake configuration for gflags, will perform search for installed gflags components.
-- Failed to find gflags - Could not find gflags include directory, set GFLAGS_INCLUDE_DIR to directory containing gflags/gflags.h
-- Failed to find glog - Could not find glog include directory, set GLOG_INCLUDE_DIR to directory containing glog/logging.h
-- Module opencv_sfm disabled because the following dependencies are not found: Eigen Glog/Gflags
-- Checking for module 'tesseract'
--   No package 'tesseract' found
-- Tesseract:   NO
-- Allocator metrics storage type: 'long long'
-- Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': /home/user/Downloads/openCV2/opencv-master/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
-- opencv_dnn: filter out cuda4dnn source code
-- rgbd: Eigen support is disabled. Eigen is Required for Posegraph optimization
-- Building with NVIDIA Optical Flow API 2.0
-- 
-- General configuration for OpenCV 4.5.2-dev =====================================
--   Version control:               unknown
-- 
--   Extra modules:
--     Location (extra):            /home/user/Downloads/openCV2/opencv_contrib-master/modules
--     Version control (extra):     unknown
-- 
--   Platform:
--     Timestamp:                   2021-05-27T14:29:27Z
--     Host:                        Linux 5.10.0-051000-generic x86_64
--     CMake:                       3.16.3
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               Release
-- 
--   CPU/HW features:
--     Baseline:                    SSE SSE2 SSE3
--       requested:                 SSE3
--     Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
--       requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
--       SSE4_1 (17 files):         + SSSE3 SSE4_1
--       SSE4_2 (2 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
--       FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
--       AVX (5 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
--       AVX2 (31 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
--       AVX512_SKX (7 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
-- 
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ standard:                11
--     C++ Compiler:                /usr/bin/g++-8  (ver 8.4.0)
--     C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /usr/bin/gcc-8
--     C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):      -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed  
--     Linker flags (Debug):        -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed  
--     ccache:                      NO
--     Precompiled headers:         NO
--     Extra dependencies:          m pthread /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so cudart_static dl rt nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/lib/x86_64-linux-gnu -L/usr/local/cuda/lib64/stubs
--     3rdparty dependencies:
-- 
--   OpenCV modules:
--     To be built:                 aruco barcode bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab viz wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 alphamat hdf java julia matlab ovis python2 sfm
--     Applications:                tests perf_tests apps
--     Documentation:               NO
--     Non-free algorithms:         NO
-- 
--   GUI: 
--     QT:                          YES (ver 5.12.8)
--       QT OpenGL support:         YES (Qt5::OpenGL 5.12.8)
--     GTK+:                        NO
--     OpenGL support:              YES (/usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so)
--     VTK support:                 YES (ver 9.0.1)
-- 
--   Media I/O: 
--     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
--     JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
--     WEBP:                        build (ver encoder: 0x020f)
--     PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.37)
--     TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.1.0)
--     JPEG 2000:                   build (ver 2.4.0)
--     OpenEXR:                     /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 2_3)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--     PFM:                         YES
-- 
--   Video I/O:
--     DC1394:                      YES (2.2.5)
--     FFMPEG:                      YES
--       avcodec:                   YES (58.134.100)
--       avformat:                  YES (58.76.100)
--       avutil:                    YES (56.70.100)
--       swscale:                   YES (5.9.100)
--       avresample:                YES (4.0.0)
--     GStreamer:                   YES (1.16.2)
--     v4l/v4l2:                    YES (linux/videodev2.h)
-- 
--   Parallel framework:            pthreads
-- 
--   Trace:                         YES (with Intel ITT)
-- 
--   Other third-party libraries:
--     Intel IPP:                   2020.0.0 Gold [2020.0.0]
--            at:                   /home/user/Downloads/openCV2/build/3rdparty/ippicv/ippicv_lnx/icv
--     Intel IPP IW:                sources (2020.0.0)
--               at:                /home/user/Downloads/openCV2/build/3rdparty/ippicv/ippicv_lnx/iw
--     VA:                          NO
--     Lapack:                      NO
--     Eigen:                       NO
--     Custom HAL:                  NO
--     Protobuf:                    build (3.5.1)
-- 
--   NVIDIA CUDA:                   YES (ver 10.1, CUFFT CUBLAS)
--     NVIDIA GPU arch:             30 35 37 50 52 60 61 70 75
--     NVIDIA PTX archs:
-- 
--   cuDNN:                         NO
-- 
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/user/Downloads/openCV2/opencv-master/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
-- 
--   Python 3:
--     Interpreter:                 /usr/bin/python3 (ver 3.8.5)
--     Libraries:                   /usr/lib/x86_64-linux-gnu/libpython3.8.so (ver 3.8.5)
--     numpy:                       /usr/lib/python3/dist-packages/numpy/core/include (ver 1.17.4)
--     install path:                lib/python3.8/dist-packages/cv2/python-3.8
-- 
--   Python (for build):            /usr/bin/python3
-- 
--   Java:                          
--     ant:                         NO
--     JNI:                         NO
--     Java wrappers:               NO
--     Java tests:                  NO
-- 
--   Install to:                    /usr/local
-- -----------------------------------------------------------------
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/Downloads/openCV2/build

Thanks again for your support!

PS: Of course I found the ‘TODO: other options: WITH_CUFFT , WITH_CUBLAS , WITH_NVCUVID ?’ in the config reference, which is ironic.

I would say you need to ask someone who has built more recently on linux. The last time I built on linux was with CUDA 10 and the older version of the Video Codec SDK. I just had a quick look at the config and it seems all I did was to include the .h files in

/usr/local/cuda/targets/x86_64-linux/include/

Then I just built with -DWITH_NVCUVID=ON not with -DBUILD_CUDA_STUBS=ON. I am pretty sure you don’t need to sym link to the stubs as I said before. On inspection of the cmake-gui the libnvcuvid.so was picked up in

/usr/lib/x86_64-linux-gnu/libnvcuvid.so

Thanks for your ideas!

Does that mean I have to pass the .h files in the cmake command as well? I suppose you are referring to the " Trying to build NVIDIA VIDEO CODEC SDK" from above?

Are you suggesting, that I try building openCV again, just without the DBUILD_CUDA_STUBS=ON?

I have not built on linux in over a year so I am not the best person to ask. You definitely don’t want DBUILD_CUDA_STUBS=ON and if it was me I would copy the headers where I suggested use the -DWITH_NVCUVID=ON flag and see if NVCUVID is picked up by cmake.
NVIDIA CUDA: YES (ver 11.1, CUFFT CUBLAS NVCUVID FAST_MATH)
You don’t need to build it, just make sure CMake is picking it up, use a new build folder to check.

Additionally before building everything to speed up the build process and quickly check cudacodec is working I would restrict the compute capability to your graphics card and disable all the other cuda modules, using the following CUDA options.

-DWITH_CUDA=ON -DCUDA_ARCH_PTX=<YOUR GPUS COMPUTE CAPABILITY> -DWITH_NVCUVID=ON -DBUILD_opencv_cudaarithm=OFF -DBUILD_opencv_cudabgsegm=OFF -DBUILD_opencv_cudafeatures2d=OFF -DBUILD_opencv_cudafilters=OFF -DBUILD_opencv_cudaimgproc=OFF -DBUILD_opencv_cudalegacy=OFF -DBUILD_opencv_cudaobjdetect=OFF -DBUILD_opencv_cudaoptflow=OFF -DBUILD_opencv_cudastereo=OFF -DBUILD_opencv_cudawarping=OFF -DBUILD_opencv_cudacodec=ON

Thanks for the advice. I’ve created a new build folder and performed the following command:
cmake \
-DWITH_CUDA=ON \
-DWITH_NVCUVID=ON \
-DWITH_OPENGL=ON \
-DWITH_QT=ON \
-DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-master/modules \
-DCMAKE_C_COMPILER=$(which gcc-8) \
-DCMAKE_CXX_COMPILER=$(which g++-8) \
../opencv-master

The result is unchanged unfortunately:

– NVIDIA CUDA: YES (ver 10.1, CUFFT CUBLAS)

So possibly copying the header files is necessary. Where can I find the header files? Where should I copy them to?

They should be in the Interface directory of the Video Codec SDK.

2 Likes

Thanks a ton cudawarped! It worked!! :tada:

Solution:
From the NVIDIA Video Codec SDK folder

Video_Codec_SDK_11.0.10/Interface/

I copied the three header files

cuviddec.h
nvcuvid.h
nvEncodeAPI.h

to the local folder

/usr/local/cuda/targets/x86_64-linux/include/

Result:
I finally get the NVCUVID to show up during the configuration of openCV!

NVIDIA CUDA:                   YES (ver 11.5, CUFFT CUBLAS **NVCUVID**)
1 Like

That’s great.

Did you also have to pass the location of the stubs for it to detect NVCUVID?


-DCUDA_nvcuvid_LIBRARY=~/stubs/nvcuvid/libnvcuvid.so

No, I did not have to! Sorry for the late reply.

Unfortunately, I’m still having trouble with the VideoReader. I’m about to open a post about that.

Thanks again for your help!