Error Compiling Opencv With CUDA

II tried to compile opencv with cuda and got this error:

error: conversion from ‘cv::cuda::Stream’ to non-scalar type ‘cv::Ptrcv::cuda::Stream’ requested
39041 | Ptrcv::cuda::Stream stream=cuda::Stream::Null();

Please provide a MRE.

I put the following 2 commands to compile opencv with cuda:

wget -O opencv.zip https://github.com/opencv/opencv/archive/refs/tags/4.8.0.zip ; wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/refs/tags/4.8.0.zip ; unzip opencv.zip ; unzip opencv_contrib.zip ; mv opencv_contrib-4.8.0 opencv_contrib ; cd opencv-4.8.0/build/ ;

AND:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D WITH_CUDA=ON -D OPENCV_DNN_CUDA=ON -D CUDA_ARCH_BIN=7.5 -D CMAKE_C_COMPILER=/usr/bin/gcc-11 -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_opencv_python2=OFF -D BUILD_opencv_java=OFF -D PYTHON3_EXECUTABLE=/home/dani/anaconda3/bin/python3 -D WITH_TBB=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1 -D BUILD_opencv_cudacodec=ON -D WITH_CUDNN=ON -D CUDNN_VERSION=8.9.5 -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_GSTREAMER=ON -D OPENCV_GENERATE_PKGCONFIG=YES -D OPENCV_PC_FILE_NAME=opencv.pc -D OPENCV_ENABLE_NONFREE=ON -D OPENCV_PYTHON3_INSTALL_PATH=/home/dani/anaconda3/lib/python3.11/site-packages -D PYTHON_EXECUTABLE=/home/dani/anaconda3/bin/python -D OPENCV_EXTRA_MODULES_PATH=/home/dani/opencv_contrib/modules -D INSTALL_PYTHON_EXAMPLES=OFF -D INSTALL_C_EXAMPLES=OFF -D BUILD_EXAMPLES=OFF … \

And at 99% i had the next error:
error: conversion from ‘cv::cuda::Stream’ to non-scalar type ‘cv::Ptrcv::cuda::Stream’ requested
39041 | Ptrcv::cuda::Stream stream=cuda::Stream::Null();

My Cuda version is 12.2 , my ubuntu version is 22.04, my cuDNN is 8.7.5 and opencv is 4.8

Thanks in advance for help!!!

Don’t open two issues for same problem

Sorry, i am New in dev, i will remove The second

I am currently unable to reproduce your error when I use the same config excluding the following options

-D CUDNN_VERSION=8.9.5 -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_GSTREAMER=ON

I get the error mentioned in

due to using OpenCV 4.8.0 with CUDA 12.2 but not

Can you post your configuration output and more of the build output regarding the error, specifically do you know which OpenCV module is causing this error? e.g. do you get the error with

cmake --build /home/dani/opencv-4.8.0/build/ --target opencv_core