cuda opencv GPU模块的使用出错

#include
#include
#include
#include
#include
#include
#include

int main()
{
int num_devices = cv::gpu::getCudaEnabledDeviceCount();
if (num_devices <= 0)
{
std::cerr << "There is no devoce" << std::endl;
return -1;
}
int enable_device_id = -1;
for (int i = 0; i < num_devices; i++)
{
cv::gpu::DeviceInfo dev_info(i);
if (dev_info.isCompatible())
{
enable_device_id = i;
}
}
if (enable_device_id < 0)
{
std::cerr << "GPU module isn't built for GPU" << std::endl;
return -1;
}

cv::gpu::setDevice(enable_device_id);

cv::Mat src_image = cv::imread("test.jpg");
cv::Mat dst_image;

cv::gpu::GpuMat d_dst_img;
cv::gpu::GpuMat d_src_img(src_image);//upload src image to gpu

//为什么从这以后的代码不执行了

printf("abcd");//测试使用
//cv::gpu::cvtColor(d_src_img, d_dst_img, CV_BGR2GRAY);
//d_dst_img.download(dst_image);//download dst image to cpu
//cv::imshow("test", dst_image);
cv::imshow("test", src_image);
cv::waitKey(5000);
return 0;
}
我感觉我配置的环境应该没问题啊,

代码不执行是后面代码没生效还是代码出错异常了。先要定位具体出错的函数,然后看是否参数等不正确

 <span style="font-size:18px;">// first.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <iostream>
#include "opencv2/opencv.hpp"
#include "opencv2/gpu/gpu.hpp"

#pragma comment(lib,"opencv_gpu2410.lib")
#pragma comment(lib,"opencv_core2410.lib")

using namespace std; 
using namespace cv; 
using namespace cv::gpu;
int main()
{
    int i;
    try
    {
        cout << getCudaEnabledDeviceCount();
    }
    catch(const cv::Exception& ex)
    {
        cout << "Error:" << ex.what() <<endl;
    }
    system("PAUSE");
    return 0;
}
</span>

你确定上面有东西,才是环境好的,要不就是你代码的问题,我试过opencv +cuda版本的,感觉bug非常多