2

私はcudaでopencvを始めたばかりです。私は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;
}
4

1 に答える 1

1

CUDA サポートなしで OpenCV をコンパイルしている必要があります

gpu::getCudaEnabledDeviceCount インストールされている CUDA 対応デバイスの数を返します。

C++: int gpu::getCudaEnabledDeviceCount()

この関数は、他の GPU 関数呼び出しの前に使用してください。OpenCV が GPU サポートなしでコンパイルされた場合、この関数は 0 を返します。

于 2013-10-12T12:59:57.260 に答える