Ask Your Question

Surf_Gpu needs Cuda ?

asked 2017-04-15 04:00:57 -0500

DEHANDPI gravatar image

I'm applying Surf_Gpu algorithm with OpenCv on Qt. When I run the code (here is the critical function):

void surf(Mat img,QString j)

int MinHessian=400;
GpuMat imgGpu;
SURF_GPU algo(MinHessian);

vector<KeyPoint> keypointsCPU;
vector<float> descriptorsCPU;
GpuMat descriptors,keypoints;

algo.downloadKeypoints(keypoints, keypointsCPU);
 algo.downloadDescriptors(descriptors, descriptorsCPU);
 // from device to host

 string path;
    path = "requete.txt";
    path = "SURF/" + j.toStdString().substr(0,j.toStdString().find(".")) +".txt";
FileStorage fs(path, FileStorage::WRITE);
fs << "SURF" << descriptorsCPU;

I have the following error message :

OpenCV Error: No GPU support (The library is compiled without CUDA support) in mallocPitch, file /build/buildd/opencv-2.4.8+dfsg1/modules/dynamicuda/include/opencv2/dynamicuda/dynamicuda.hpp, line 126 terminate called after throwing an instance of 'cv::Exception' what(): /build/buildd/opencv-2.4.8+dfsg1/modules/dynamicuda/include/opencv2/dynamicuda/dynamicuda.hpp:126: error: (-216) The library is compiled without CUDA support in function mallocPitch

though I don't explicitely use Cuda... Here are my includes:

#include <stdio.h>
#include <QMainWindow>
#include <QFileDialog>
#include <QImage>
#include <QStandardItemModel>
#include <QItemSelectionModel>
#include <QMessageBox>
// #include <highgui.h>
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/nonfree/nonfree.hpp>
#include <opencv2/nonfree/features2d.hpp>
#include <opencv2/nonfree/gpu.hpp>
#include <opencv2/stitching/detail/matchers.hpp>
// for BFMatcher
#include <opencv2/gpu/gpu.hpp>
#include <fstream>
#include <sstream>
#include <iostream>
#include <QTime>
#include <sstream>
#include <QString>

What shall I need to do to get rid of the error ? Thanks !

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-04-15 04:19:39 -0500

berak gravatar image

updated 2017-04-15 04:21:17 -0500

well, you can't use GpuMat, SURF_GPU (or anything with gpu in it) without CUDA support built into the opencv libs at compile time

to achieve it, you'd have to

  • have hardware, that supports CUDA
  • get more recent opencv src (2.4.8 is very old)
  • get a recent CUDA sdk (v 8.0, iirc)
  • rebuild opencv libs from src with cmake -DWITH_CUDA=ON

opencv-2.4.8+dfsg1 looks like something very outdated, that you grabbed pre-built from some package manager. those versions are all "plain vanilla", and do not have any hardware support (apart from opencl, maybe)

edit flag offensive delete link more


Thanks for your answer. Actually, the latest version of opencv I have is 2.4.10. I saw that there are one version of each lib-corresponding to the version of opencv. In my .pro in Qt, when I add the libs, how can I be sure that it's the latest version (apparently, it's not the case yet, because the error message tell it's opencv 2.4.8). Thanks!

DEHANDPI gravatar imageDEHANDPI ( 2017-04-15 04:44:31 -0500 )edit

"how can I be sure that it's the latest version" -- build from github src

even if you want to stay on outdated 2.4 branch, latest current release is

berak gravatar imageberak ( 2017-04-15 04:48:04 -0500 )edit

I looked at this : (link text) and it seems that Cuda was well supported with older opencv versions... I checked the cmake; the WITH_CUDA is well on. So I don't know from where it could come. Do you have any more idea?

DEHANDPI gravatar imageDEHANDPI ( 2017-04-15 08:22:56 -0500 )edit

check cerr << cv::getBuildInformation(); to see, what hardware support actually made it into your opencv libs

(yes, older 2.4 version supported cuda, too, but yours was obviously build without)

berak gravatar imageberak ( 2017-04-15 08:26:02 -0500 )edit

Thanks Berak Here is what I have:

Unavailable:                 androidcamera dynamicuda

Indeed... But why is it opencv 2.4.8 that is used although the opencv 2.4.10 is also built, WITH_CUDA on? How can I "switch" from 2.4.8 to 2.4.10 in my Qt program? Maybe a silly question but I'm quite new with all this (student). Thanks for help/interesting link !

DEHANDPI gravatar imageDEHANDPI ( 2017-04-16 05:13:39 -0500 )edit

@berak Could you have a look at my previous comment please?

DEHANDPI gravatar imageDEHANDPI ( 2017-04-19 07:32:32 -0500 )edit

@SurfMan, sorry, i have no idea.

berak gravatar imageberak ( 2017-04-19 09:44:32 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-04-15 04:00:57 -0500

Seen: 266 times

Last updated: Apr 15 '17