gpt4 book ai didi

c++ - OPENCV CUDA -- getCudaEnabledDeviceCount 返回 0

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:25:58 25 4
gpt4 key购买 nike

我刚接触 opencv 和 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 返回 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;
}

最佳答案

你肯定编译过没有CUDA支持的OpenCV

gpu::getCudaEnabledDeviceCount Returns the number of installed CUDA-enabled devices.

C++: int gpu::getCudaEnabledDeviceCount()

Use this function before any other GPU functions calls. If OpenCV is compiled without GPU support, this function returns 0.

关于c++ - OPENCV CUDA -- getCudaEnabledDeviceCount 返回 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19334371/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com