简体   繁体   English

OpenCV 错误:Gpu API 调用(无效的设备符号)在 loadGlobalConstants,.../xfeatures2d/src/cuda/surf.cu

[英]OpenCV Error: Gpu API call (invalid device symbol) in loadGlobalConstants, …/xfeatures2d/src/cuda/surf.cu, line 109

I got an error when performing "surf(img1, cv::cuda::GpuMat(), keypoints1GPU, descriptors1GPU);"执行“surf(img1, cv::cuda::GpuMat(), keypoints1GPU, descriptors1GPU);”时出现错误which exactly refers to https://github.com/opencv/opencv/blob/3.4/samples/gpu/surf_keypoint_matcher.cpp The c++ code is:这正是指https://github.com/opencv/opencv/blob/3.4/samples/gpu/surf_keypoint_matcher.cpp c++ 代码是:

{
    ...
    cv::cuda::GpuMat img1, img2;
    img1.upload(imread("query.jpg", IMREAD_GRAYSCALE));
    CV_Assert(!img1.empty());
    img2.upload(imread("ref.jpg", IMREAD_GRAYSCALE));
    CV_Assert(!img2.empty());
    cv::cuda::printShortCudaDeviceInfo(cv::cuda::getDevice());
    cv::cuda::SURF_CUDA surf;
    cv::cuda::GpuMat keypoints1GPU, keypoints2GPU;
    cv::cuda::GpuMat descriptors1GPU, descriptors2GPU;
    surf(img1, GpuMat(), keypoints1GPU, descriptors1GPU);
    surf(img2, GpuMat(), keypoints2GPU, descriptors2GPU);
    ...
}

The error details: OpenCV Error: Gpu API call (invalid device symbol) in loadGlobalConstants, file /tmp/opencv/opencv/opencv_contrib/modules/xfeatures2d/src/cuda/surf.cu, line 109 The error details: OpenCV Error: Gpu API call (invalid device symbol) in loadGlobalConstants, file /tmp/opencv/opencv/opencv_contrib/modules/xfeatures2d/src/cuda/surf.cu, line 109

Device info.: Device 0: "Tesla V100-SXM2-32GB" 32256Mb, sm_70, Driver/Runtime ver.10.10/10.0 Driver Version: 418.39 CUDA Version: 10.1设备信息:设备 0:“Tesla V100-SXM2-32GB”32256Mb,sm_70,驱动程序/运行时版本 10.10/10.0 驱动程序版本:418.39 CUDA 版本:10.1

OpenCV info.: version 3.2.0 OpenCV 信息:版本 3.2.0

Any ideas would be greatly appreciated.任何想法将不胜感激。

I've experienced the same problem and found the solution via the help of this thread我遇到了同样的问题,并通过此线程的帮助找到了解决方案

It seems like there is a problem related to indexing in OpenCV functions.似乎在 OpenCV 函数中存在与索引相关的问题。 In your case, changing code as I show below should work:在您的情况下,如下所示更改代码应该可以工作:

{
    ...
    cv::cuda::GpuMat img1, img2, img1dummy, img2dummy;
    img1dummy.upload(imread("query.jpg", IMREAD_GRAYSCALE));
    CV_Assert(!img1dummy.empty());
    img2dummy.upload(imread("ref.jpg", IMREAD_GRAYSCALE));
    CV_Assert(!img2dummy.empty());
    cv::cuda::printShortCudaDeviceInfo(cv::cuda::getDevice());
    cv::cuda::SURF_CUDA surf;
    cv::cuda::GpuMat keypoints1GPU, keypoints2GPU;
    cv::cuda::GpuMat descriptors1GPU, descriptors2GPU;
    img1 = img1dummy.clone();
    img2 = img2dummy.clone();
    surf(img1, GpuMat(), keypoints1GPU, descriptors1GPU);
    surf(img2, GpuMat(), keypoints2GPU, descriptors2GPU);
    ...
}

My OpenCV version is 4.2.0.我的 OpenCV 版本是 4.2.0。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM