Simple GPU access tutorials with OpenCV
Forgive the broad OpenCV/C++/CUDA/GpuMat question, but does anyone know of a simple tutorial for converting an OpenCV Mat image file to a GpuMat? I've spent the entire weekend looking around, and it appears that the OpenCV GPU functions have changed a lot over time, and tutorials from a few years ago no longer apply.
And compound that with the challenge of setting up CUDA and OpenCV and CMake in a Visual Studio C++ so that you also have GPU support and it's time to tear your hair out.
The closest I've come is this, although this is like the 5th syntax I've tried from different tutorials. It compiles and links okay, but crashes with a "no CUDA support" error:
using namespace cv;
Mat image = imread("d:\\documents\\renders\\img.bmp");
cuda::GpuMat gI; // GPU matrix - for now empty
gI.upload(image); // Upload a data from the system memory to the GPU memory
Thanks much for any help
The code looks fine. Can you see where the error comes from? What's the output of getCudaEnabledDeviceCount()?
Thanks. Not at my machine right now but I have 2 GPU's, a GTX 1070 and 1080ti which presumably are both CUDA enabled. Maybe I need to specify just one device as the target (cudaSetDevice())?
Strange. When I run getCudaEnabledDeviceCount() it returns 0, which means no cuda devices exist. But I'm running cuda code in a separate CUDA app on the gpu's and I can query them fine (cudaGetDeviceProperties()). Also, "cudaGetDeviceCount() returns 2. Anyone know why OpenCV has a problem? thx.
Possibly something went wrong when you compiled OpenCV with CUDA. What's the output of getBuildInformation() in your OpenCV app? There should be a field
Use Cuda
, does it say YES or NO?