首页 文章

OPENCV CUDA - getCudaEnabledDeviceCount返回0

提问于
浏览
2

我对cuda很开心 . 我使用opencv2.4.6和CUDA4.2 . 我已成功用cuda编译opencv . 当我使用代码时:

int cuda_count;
cudaError_t error = cudaGetDeviceCount( &cuda_count );

它返回 cudaSuccesscuda_count=1 但是,当我使用代码时:

int num_devices = cv::gpu::getCudaEnabledDeviceCount();

num_devices returns 0 为什么?

我的完整代码是:

int main()
{

int num_devices = cv::gpu::getCudaEnabledDeviceCount();

    int cuda_count;
    cudaError_t error = cudaGetDeviceCount( &cuda_count );

    if(num_devices <=0 )
    {
        std::cerr << "no" << std::endl;
        return -1;
    }

    int enable_devivce_id = -1;
}

1 回答

  • 1

    您必须在没有CUDA支持的情况下编译OpenCV

    gpu :: getCudaEnabledDeviceCount返回已安装的支持CUDA的设备的数量 . C:int gpu :: getCudaEnabledDeviceCount()在任何其他GPU函数调用之前使用此函数 . 如果在没有GPU支持的情况下编译OpenCV,则此函数返回0 .

相关问题