# Error Compiling Opencv With CUDA

**URL:** <https://forum.opencv.org/t/error-compiling-opencv-with-cuda/14605>\
**Category:** Python\
**Tags:** cuda\
**Created:** [September 20, 2023, 2:11pm UTC](https://forum.opencv.org/t/error-compiling-opencv-with-cuda/14605 "2023-09-20T14:11:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrei\_Cosma](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/andrei_cosma/32/8081_2.png) [@Andrei\_Cosma](https://forum.opencv.org/u/Andrei_Cosma)\
**Post date:** [September 20, 2023, 2:11pm UTC](https://forum.opencv.org/t/error-compiling-opencv-with-cuda/14605/1 "2023-09-20T14:11:34Z")

</div>

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();

---

<div class="post-metadata">

**Author:** ![cudawarped](https://avatars.discourse-cdn.com/v4/letter/c/9dc877/32.png) [@cudawarped](https://forum.opencv.org/u/cudawarped)\
**Post date:** [September 20, 2023, 2:18pm UTC](https://forum.opencv.org/t/error-compiling-opencv-with-cuda/14605/2 "2023-09-20T14:18:41Z")

</div>

Please provide a [MRE](https://stackoverflow.com/help/minimal-reproducible-example).

---

<div class="post-metadata">

**Author:** ![Andrei\_Cosma](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/andrei_cosma/32/8081_2.png) [@Andrei\_Cosma](https://forum.opencv.org/u/Andrei_Cosma)\
**Post date:** [September 21, 2023, 8:14am UTC](https://forum.opencv.org/t/error-compiling-opencv-with-cuda/14605/3 "2023-09-21T08:14:28Z")

</div>

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](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](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!!!

---

<div class="post-metadata">

**Author:** ![laurent.berger](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@laurent.berger](https://forum.opencv.org/u/laurent.berger)\
**Post date:** [September 21, 2023, 8:20am UTC](https://forum.opencv.org/t/error-compiling-opencv-with-cuda/14605/4 "2023-09-21T08:20:42Z")

</div>

Don’t open two issues for same problem

> <https://github.com/opencv/opencv/issues/24304>
>
> \### System Information
> 
> II tried to compile opencv with cuda and got this error:…
> 
> error: conversion from ‘cv::cuda::Stream’ to non-scalar type ‘cv::Ptr\<cv::cuda::Stream\>’ requested
> 39041 | Ptr\<cv::cuda::Stream\> stream=cuda::Stream::Null();
> 
> \### Detailed description
> 
> II tried to compile opencv with cuda and got this error:
> 
> error: conversion from ‘cv::cuda::Stream’ to non-scalar type ‘cv::Ptr\<cv::cuda::Stream\>’ requested
> 39041 | Ptr\<cv::cuda::Stream\> stream=cuda::Stream::Null();
> 
> \### Steps to reproduce
> 
> II tried to compile opencv with cuda and got this error:
> 
> error: conversion from ‘cv::cuda::Stream’ to non-scalar type ‘cv::Ptr\<cv::cuda::Stream\>’ requested
> 39041 | Ptr\<cv::cuda::Stream\> stream=cuda::Stream::Null();
> 
> \### Issue submission checklist
> 
> \- \[X\] I report the issue, it's not a question
> \- \[X\] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
> \- \[X\] I updated to the latest OpenCV version and the issue is still there
> \- \[X\] There is reproducer code and related data files (videos, images, onnx, etc)

> <https://github.com/opencv/opencv/issues/24306>
>
> \### System Information
> 
> I put the following 2 commands to compile opencv with cu…da:
> 
> 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!!!
> 
> \### Detailed description
> 
> 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!!!
> 
> \### Steps to reproduce
> 
> 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!!!
> 
> \### Issue submission checklist
> 
> \- \[X\] I report the issue, it's not a question
> \- \[X\] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
> \- \[X\] I updated to the latest OpenCV version and the issue is still there
> \- \[X\] There is reproducer code and related data files (videos, images, onnx, etc)

---

<div class="post-metadata">

**Author:** ![OfficeKid](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/officekid/32/8746_2.png) [@OfficeKid](https://forum.opencv.org/u/OfficeKid)\
**Post date:** [September 21, 2023, 8:24am UTC](https://forum.opencv.org/t/error-compiling-opencv-with-cuda/14605/5 "2023-09-21T08:24:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cudawarped](https://avatars.discourse-cdn.com/v4/letter/c/9dc877/32.png) [@cudawarped](https://forum.opencv.org/u/cudawarped)\
**Post date:** [September 21, 2023, 9:14am UTC](https://forum.opencv.org/t/error-compiling-opencv-with-cuda/14605/6 "2023-09-21T09:14:55Z")

</div>

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

> <https://github.com/opencv/opencv/issues/24304#issuecomment-1729306215>
>
> \### System Information
> 
> II tried to compile opencv with cuda and got this error:…
> 
> error: conversion from ‘cv::cuda::Stream’ to non-scalar type ‘cv::Ptr\<cv::cuda::Stream\>’ requested
> 39041 | Ptr\<cv::cuda::Stream\> stream=cuda::Stream::Null();
> 
> \### Detailed description
> 
> II tried to compile opencv with cuda and got this error:
> 
> error: conversion from ‘cv::cuda::Stream’ to non-scalar type ‘cv::Ptr\<cv::cuda::Stream\>’ requested
> 39041 | Ptr\<cv::cuda::Stream\> stream=cuda::Stream::Null();
> 
> \### Steps to reproduce
> 
> II tried to compile opencv with cuda and got this error:
> 
> error: conversion from ‘cv::cuda::Stream’ to non-scalar type ‘cv::Ptr\<cv::cuda::Stream\>’ requested
> 39041 | Ptr\<cv::cuda::Stream\> stream=cuda::Stream::Null();
> 
> \### Issue submission checklist
> 
> \- \[X\] I report the issue, it's not a question
> \- \[X\] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
> \- \[X\] I updated to the latest OpenCV version and the issue is still there
> \- \[X\] There is reproducer code and related data files (videos, images, onnx, etc)

due to using OpenCV 4.8.0 with CUDA 12.2 but not

> [@Andrei\_Cosma](#):
>
> error: conversion from ‘cv::cuda::Stream’ to non-scalar type ‘cv::Ptrcv::cuda::Stream’

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
