I compiled OpenCV3 in Windows 10 with CUDA, the compilation was succesful. I am using:
- Visual Studio 2015 in Windows 10
- CUDA 9.1
- NVIDIA Quadro P5000
- OpenCV 3.4.1
It compiles and I am able to do image processing without CUDA. When I use CUDA, I can detect the NVIDIA device and all its properties but I cannot call any image processing function. Maybe I am missing some configuration. This is the output with the error I get:
CUDA with OPENCV test program
<1> CUDA device(s) found
[CUDA Device 0]
name: Quadro P5000
majorVersion: 6
minorVersion: 1
multiProcessorCount: 20
maxThreadsPerMultiProcessor: 2048
maxThreadsPerBlock: 1024
sharedMemPerBlock: 49152
freeMemory: 14367404851
totalMemory: 17179869184
isCompatible: 1
supports(FEATURE_SET_COMPUTE_10): 1
supports(FEATURE_SET_COMPUTE_11): 1
supports(FEATURE_SET_COMPUTE_12): 1
supports(FEATURE_SET_COMPUTE_13): 1
supports(FEATURE_SET_COMPUTE_20): 1
supports(FEATURE_SET_COMPUTE_21): 1
supports(FEATURE_SET_COMPUTE_30): 1
supports(FEATURE_SET_COMPUTE_32): 1
supports(FEATURE_SET_COMPUTE_35): 1
supports(FEATURE_SET_COMPUTE_50): 1
supports(FEATURE_SET_COMPUTE_52): 1
supports(FEATURE_SET_COMPUTE_60): 1
supports(FEATURE_SET_COMPUTE_61): 1
supports(FEATURE_SET_COMPUTE_70): 0
OpenCV(3.4.1) Error: Gpu API call (invalid configuration argument) in cv::cudev::grid_transform_detail::TransformDispatcher<true, Policy>::call, file c:\opencv3_20180329\opencv-3.4.1\modules\cudev\include\opencv2\cudev\grid\detail/transform.hpp, line 318
Error: OpenCV(3.4.1) c:\opencv3_20180329\opencv-3.4.1\modules\cudev\include\opencv2\cudev\grid\detail/transform.hpp:318: error: (-217) invalid configuration argument in function cv::cudev::grid_transform_detail::TransformDispatcher<true, Policy>::call
This is the code I am using.
#include <iostream>
#include "opencv2/opencv.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/cudaimgproc.hpp"
#include "opencv2/cudaarithm.hpp"
int main(int argc, char* argv[])
{
std::cout << "\nCUDA with OPENCV test program";
int cudaDevices = cv::cuda::getCudaEnabledDeviceCount();;
if (cudaDevices > 0)
{
std::cout << "\n<" << cudaDevices << "> CUDA device(s) found" << std::endl;
for (int i_device = 0; i_device < cudaDevices; i_device++)
{
cv::cuda::DeviceInfo info(i_device);
std::cout <<
"[CUDA Device " << i_device << "]" << std::endl <<
"name: " << info.name() << std::endl <<
"majorVersion: " << info.majorVersion() << std::endl <<
"minorVersion: " << info.minorVersion() << std::endl <<
"multiProcessorCount: " << info.multiProcessorCount() << std::endl <<
"maxThreadsPerMultiProcessor: " << info.maxThreadsPerMultiProcessor() << std::endl <<
"maxThreadsPerBlock: " << info.maxThreadsPerBlock() << std::endl <<
"sharedMemPerBlock: " << info.sharedMemPerBlock() << std::endl <<
"freeMemory: " << info.freeMemory() << std::endl <<
"totalMemory: " << info.totalMemory() << std::endl <<
"isCompatible: " << info.isCompatible() << std::endl <<
"supports(FEATURE_SET_COMPUTE_10): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_10) << std::endl <<
"supports(FEATURE_SET_COMPUTE_11): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_11) << std::endl <<
"supports(FEATURE_SET_COMPUTE_12): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_12) << std::endl <<
"supports(FEATURE_SET_COMPUTE_13): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_13) << std::endl <<
"supports(FEATURE_SET_COMPUTE_20): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_20) << std::endl <<
"supports(FEATURE_SET_COMPUTE_21): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_21) << std::endl <<
"supports(FEATURE_SET_COMPUTE_30): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_30) << std::endl <<
"supports(FEATURE_SET_COMPUTE_32): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_32) << std::endl <<
"supports(FEATURE_SET_COMPUTE_35): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_35) << std::endl <<
"supports(FEATURE_SET_COMPUTE_50): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_50) << std::endl <<
"supports(FEATURE_SET_COMPUTE_52): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_52) << std::endl <<
"supports(FEATURE_SET_COMPUTE_60): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_60) << std::endl <<
"supports(FEATURE_SET_COMPUTE_61): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_61) << std::endl <<
"supports(FEATURE_SET_COMPUTE_70): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_70) << std::endl;
}
}
else
std::cout << "\nCUDA not enabled on this machine";
cv::cuda::setDevice(0);
try
{
cv::Mat src_host = cv::imread("lena.png", cv::IMREAD_GRAYSCALE);
cv::cuda::GpuMat dst, src;
src.upload(src_host);
cv::cuda::threshold(src, dst, 128.0, 255.0, cv::THRESH_BINARY);
cv::Mat result_host;
dst.download(result_host);
//cv::imshow("Result", result_host);
//cv::waitKey();
}
catch (const cv::Exception& ex)
{
std::cout << "Error: " << ex.what() << std::endl;
}
return 0;
}