2013-10-12 65 views
2

我是一個新鮮的與cuda opencv。 我使用opencv2.4.6和CUDA4.2。 我成功地用cuda編譯opencv。 當我使用的代碼:OPENCV CUDA - getCudaEnabledDeviceCount返回0

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; 
} 
+0

但是當我調試例如 「opencv_test_gpu」 的CV :: GPU :: getCudaEnabledDeviceCount()返回1;我真的很困惑。想! – user2873972

回答

1

你必須在編譯OpenCV的不支持CUDA

GPU :: getCudaEnabledDeviceCount返回已安裝 支持CUDA的設備的數量。

C++:INT GPU :: getCudaEnabledDeviceCount()

使用之前的任何 其它GPU功能調用此功能。如果OpenCV的而不GPU支持編譯, 此函數返回0