Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

GPU API Call error, invalid configuration argument when using CUDA

I compiled OpenCV3 in Windows 10 with CUDA, the compilation was succesful. I am using:

  • Visual Studio 2015 in Windows 10
  • CUDA 9.1
  • NVIDIA Quadro P5000
  • OpenCV 3.4.1

It compiles and I am able to do image processing without CUDA. When I use CUDA, I can detect the NVIDIA device and all its properties but I cannot call any image processing function. Maybe I am missing some configuration. This is the output with the error I get:

CUDA with OPENCV test program
<1> CUDA device(s) found
[CUDA Device 0]
name: Quadro P5000
majorVersion: 6
minorVersion: 1
multiProcessorCount: 20
maxThreadsPerMultiProcessor: 2048
maxThreadsPerBlock: 1024
sharedMemPerBlock: 49152
freeMemory: 14367404851
totalMemory: 17179869184
isCompatible: 1
supports(FEATURE_SET_COMPUTE_10): 1
supports(FEATURE_SET_COMPUTE_11): 1
supports(FEATURE_SET_COMPUTE_12): 1
supports(FEATURE_SET_COMPUTE_13): 1
supports(FEATURE_SET_COMPUTE_20): 1
supports(FEATURE_SET_COMPUTE_21): 1
supports(FEATURE_SET_COMPUTE_30): 1
supports(FEATURE_SET_COMPUTE_32): 1
supports(FEATURE_SET_COMPUTE_35): 1
supports(FEATURE_SET_COMPUTE_50): 1
supports(FEATURE_SET_COMPUTE_52): 1
supports(FEATURE_SET_COMPUTE_60): 1
supports(FEATURE_SET_COMPUTE_61): 1
supports(FEATURE_SET_COMPUTE_70): 0
OpenCV(3.4.1) Error: Gpu API call (invalid configuration argument) in cv::cudev::grid_transform_detail::TransformDispatcher<true, Policy>::call, file c:\opencv3_20180329\opencv-3.4.1\modules\cudev\include\opencv2\cudev\grid\detail/transform.hpp, line 318
Error: OpenCV(3.4.1) c:\opencv3_20180329\opencv-3.4.1\modules\cudev\include\opencv2\cudev\grid\detail/transform.hpp:318: error: (-217) invalid configuration argument in function cv::cudev::grid_transform_detail::TransformDispatcher<true, Policy>::call

This is the code I am using.

#include <iostream>
#include "opencv2/opencv.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/cudaimgproc.hpp"
#include "opencv2/cudaarithm.hpp"

int main(int argc, char* argv[])
{
    std::cout << "\nCUDA with OPENCV test program";

    int cudaDevices = cv::cuda::getCudaEnabledDeviceCount();;
    if (cudaDevices > 0)
    {
        std::cout << "\n<" << cudaDevices << "> CUDA device(s) found" << std::endl;
        for (int i_device = 0; i_device < cudaDevices; i_device++)
        {
            cv::cuda::DeviceInfo info(i_device);
            std::cout <<
                "[CUDA Device " << i_device << "]" << std::endl <<
                "name: " << info.name() << std::endl <<
                "majorVersion: " << info.majorVersion() << std::endl <<
                "minorVersion: " << info.minorVersion() << std::endl <<
                "multiProcessorCount: " << info.multiProcessorCount() << std::endl <<
                "maxThreadsPerMultiProcessor: " << info.maxThreadsPerMultiProcessor() << std::endl <<
                "maxThreadsPerBlock: " << info.maxThreadsPerBlock() << std::endl <<
                "sharedMemPerBlock: " << info.sharedMemPerBlock() << std::endl <<
                "freeMemory: " << info.freeMemory() << std::endl <<
                "totalMemory: " << info.totalMemory() << std::endl <<
                "isCompatible: " << info.isCompatible() << std::endl <<
                "supports(FEATURE_SET_COMPUTE_10): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_10) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_11): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_11) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_12): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_12) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_13): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_13) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_20): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_20) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_21): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_21) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_30): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_30) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_32): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_32) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_35): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_35) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_50): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_50) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_52): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_52) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_60): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_60) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_61): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_61) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_70): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_70) << std::endl;
        }
    }
    else
        std::cout << "\nCUDA not enabled on this machine";

    cv::cuda::setDevice(0);

    try
    {
        cv::Mat src_host = cv::imread("lena.png", cv::IMREAD_GRAYSCALE);
        cv::cuda::GpuMat dst, src;
        src.upload(src_host);

        cv::cuda::threshold(src, dst, 128.0, 255.0, cv::THRESH_BINARY);

        cv::Mat result_host;
        dst.download(result_host);
        //cv::imshow("Result", result_host);
        //cv::waitKey();
    }
    catch (const cv::Exception& ex)
    {
        std::cout << "Error: " << ex.what() << std::endl;
    }
    return 0;
}

GPU API Call error, invalid configuration argument when using CUDA

I compiled OpenCV3 in Windows 10 with CUDA, the compilation was succesful. I am using:

  • Visual Studio 2015 in Windows 10
  • CUDA 9.1
  • NVIDIA Quadro P5000
  • OpenCV 3.4.1

It compiles and I am able to do image processing without CUDA. When I use CUDA, I can detect the NVIDIA device and all its properties but I cannot call any image processing function. Maybe I am missing some configuration. I debugged it and found that it fails when checking for the block and grid configuration of the card, those values are passed as the Policy to the transform function but are hardcoded. It's there a way to set those values at runtime?

When I compiled OpenCV I set CUDA_ARCH_BIN and CUDA_ARCH_PTX to 6.1. Now, 6.1 is was not available before in CUDA_ARCH_BIN, but as it can be seen in the error below it is supported by the NVIDIA card I am using.

This is the output with the error I get:

CUDA with OPENCV test program
<1> CUDA device(s) found
[CUDA Device 0]
name: Quadro P5000
majorVersion: 6
minorVersion: 1
multiProcessorCount: 20
maxThreadsPerMultiProcessor: 2048
maxThreadsPerBlock: 1024
sharedMemPerBlock: 49152
freeMemory: 14367404851
totalMemory: 17179869184
isCompatible: 1
supports(FEATURE_SET_COMPUTE_10): 1
supports(FEATURE_SET_COMPUTE_11): 1
supports(FEATURE_SET_COMPUTE_12): 1
supports(FEATURE_SET_COMPUTE_13): 1
supports(FEATURE_SET_COMPUTE_20): 1
supports(FEATURE_SET_COMPUTE_21): 1
supports(FEATURE_SET_COMPUTE_30): 1
supports(FEATURE_SET_COMPUTE_32): 1
supports(FEATURE_SET_COMPUTE_35): 1
supports(FEATURE_SET_COMPUTE_50): 1
supports(FEATURE_SET_COMPUTE_52): 1
supports(FEATURE_SET_COMPUTE_60): 1
supports(FEATURE_SET_COMPUTE_61): 1
supports(FEATURE_SET_COMPUTE_70): 0
OpenCV(3.4.1) Error: Gpu API call (invalid configuration argument) in cv::cudev::grid_transform_detail::TransformDispatcher<true, Policy>::call, file c:\opencv3_20180329\opencv-3.4.1\modules\cudev\include\opencv2\cudev\grid\detail/transform.hpp, line 318
Error: OpenCV(3.4.1) c:\opencv3_20180329\opencv-3.4.1\modules\cudev\include\opencv2\cudev\grid\detail/transform.hpp:318: error: (-217) invalid configuration argument in function cv::cudev::grid_transform_detail::TransformDispatcher<true, Policy>::call

This is the code I am using.

#include <iostream>
#include "opencv2/opencv.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/cudaimgproc.hpp"
#include "opencv2/cudaarithm.hpp"

int main(int argc, char* argv[])
{
    std::cout << "\nCUDA with OPENCV test program";

    int cudaDevices = cv::cuda::getCudaEnabledDeviceCount();;
    if (cudaDevices > 0)
    {
        std::cout << "\n<" << cudaDevices << "> CUDA device(s) found" << std::endl;
        for (int i_device = 0; i_device < cudaDevices; i_device++)
        {
            cv::cuda::DeviceInfo info(i_device);
            std::cout <<
                "[CUDA Device " << i_device << "]" << std::endl <<
                "name: " << info.name() << std::endl <<
                "majorVersion: " << info.majorVersion() << std::endl <<
                "minorVersion: " << info.minorVersion() << std::endl <<
                "multiProcessorCount: " << info.multiProcessorCount() << std::endl <<
                "maxThreadsPerMultiProcessor: " << info.maxThreadsPerMultiProcessor() << std::endl <<
                "maxThreadsPerBlock: " << info.maxThreadsPerBlock() << std::endl <<
                "sharedMemPerBlock: " << info.sharedMemPerBlock() << std::endl <<
                "freeMemory: " << info.freeMemory() << std::endl <<
                "totalMemory: " << info.totalMemory() << std::endl <<
                "isCompatible: " << info.isCompatible() << std::endl <<
                "supports(FEATURE_SET_COMPUTE_10): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_10) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_11): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_11) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_12): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_12) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_13): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_13) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_20): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_20) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_21): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_21) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_30): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_30) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_32): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_32) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_35): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_35) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_50): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_50) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_52): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_52) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_60): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_60) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_61): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_61) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_70): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_70) << std::endl;
        }
    }
    else
        std::cout << "\nCUDA not enabled on this machine";

    cv::cuda::setDevice(0);

    try
    {
        cv::Mat src_host = cv::imread("lena.png", cv::IMREAD_GRAYSCALE);
        cv::cuda::GpuMat dst, src;
        src.upload(src_host);

        cv::cuda::threshold(src, dst, 128.0, 255.0, cv::THRESH_BINARY);

        cv::Mat result_host;
        dst.download(result_host);
        //cv::imshow("Result", result_host);
        //cv::waitKey();
    }
    catch (const cv::Exception& ex)
    {
        std::cout << "Error: " << ex.what() << std::endl;
    }
    return 0;
}

GPU API Call error, invalid configuration argument when using CUDA

I compiled OpenCV3 in Windows 10 with CUDA, the compilation was succesful. I am using:

  • Visual Studio 2015 in Windows 10
  • CUDA 9.1
  • NVIDIA Quadro P5000
  • OpenCV 3.4.1

It compiles and I am able to do image processing without CUDA. When I use CUDA, I can detect the NVIDIA device and all its properties but I cannot call any image processing function. Maybe I am missing some configuration. I debugged it and found that it fails when checking for the block and grid configuration of the card, those values are passed as the Policy to the transform function but are hardcoded. It's there a way to set those values at runtime?

When I compiled OpenCV I set CUDA_ARCH_BIN and CUDA_ARCH_PTX to 6.1. Now, 6.1 is was not available before in CUDA_ARCH_BIN, but as it can be seen in the error below it is supported by the NVIDIA card I am using.

Edit 1

I still cannot run the threshold code I have.

On the other hand, opencv_test_cudaarithm can run, altough I have some errors. These are the values of the variables involved in one call of the threshold funcion.

size:[128 x 128]
type:0
channel:1
threshOp:0
useRoi:0

This are the errors after running opencv_test_cudaarithm:

[----------] Global test environment tear-down
[==========] 11613 tests from 67 test cases ran. (15629 ms total)
[  PASSED  ] 11595 tests.
[  FAILED  ] 18 tests, listed below:
[  FAILED  ] CUDA_Arithm/Bitwise_Scalar.Or/8, where GetParam() = (Quadro P5000, 128x128, CV_32S, Channels(4))
[  FAILED  ] CUDA_Arithm/Bitwise_Scalar.Or/17, where GetParam() = (Quadro P5000, 113x113, CV_32S, Channels(4))
[  FAILED  ] CUDA_Arithm/Bitwise_Scalar.And/8, where GetParam() = (Quadro P5000, 128x128, CV_32S, Channels(4))
[  FAILED  ] CUDA_Arithm/Bitwise_Scalar.And/17, where GetParam() = (Quadro P5000, 113x113, CV_32S, Channels(4))
[  FAILED  ] CUDA_Arithm/Bitwise_Scalar.Xor/8, where GetParam() = (Quadro P5000, 128x128, CV_32S, Channels(4))
[  FAILED  ] CUDA_Arithm/Bitwise_Scalar.Xor/17, where GetParam() = (Quadro P5000, 113x113, CV_32S, Channels(4))
[  FAILED  ] CUDA_Arithm/PolarToCart.Accuracy/0, where GetParam() = (Quadro P5000, 128x128, AngleInDegrees(false), whole matrix)
[  FAILED  ] CUDA_Arithm/PolarToCart.Accuracy/1, where GetParam() = (Quadro P5000, 128x128, AngleInDegrees(false), sub matrix)
[  FAILED  ] CUDA_Arithm/PolarToCart.Accuracy/2, where GetParam() = (Quadro P5000, 128x128, AngleInDegrees(true), whole matrix)
[  FAILED  ] CUDA_Arithm/PolarToCart.Accuracy/3, where GetParam() = (Quadro P5000, 128x128, AngleInDegrees(true), sub matrix)
[  FAILED  ] CUDA_Arithm/PolarToCart.Accuracy/4, where GetParam() = (Quadro P5000, 113x113, AngleInDegrees(false), whole matrix)
[  FAILED  ] CUDA_Arithm/PolarToCart.Accuracy/5, where GetParam() = (Quadro P5000, 113x113, AngleInDegrees(false), sub matrix)
[  FAILED  ] CUDA_Arithm/PolarToCart.Accuracy/6, where GetParam() = (Quadro P5000, 113x113, AngleInDegrees(true), whole matrix)
[  FAILED  ] CUDA_Arithm/PolarToCart.Accuracy/7, where GetParam() = (Quadro P5000, 113x113, AngleInDegrees(true), sub matrix)
[  FAILED  ] CUDA_Arithm/MeanStdDev.Async/0, where GetParam() = (Quadro P5000, 128x128, whole matrix)
[  FAILED  ] CUDA_Arithm/MeanStdDev.Async/1, where GetParam() = (Quadro P5000, 128x128, sub matrix)
[  FAILED  ] CUDA_Arithm/MeanStdDev.Async/2, where GetParam() = (Quadro P5000, 113x113, whole matrix)
[  FAILED  ] CUDA_Arithm/MeanStdDev.Async/3, where GetParam() = (Quadro P5000, 113x113, sub matrix)

Info

This is the output with the error I get:

CUDA with OPENCV test program
<1> CUDA device(s) found
[CUDA Device 0]
name: Quadro P5000
majorVersion: 6
minorVersion: 1
multiProcessorCount: 20
maxThreadsPerMultiProcessor: 2048
maxThreadsPerBlock: 1024
sharedMemPerBlock: 49152
freeMemory: 14367404851
totalMemory: 17179869184
isCompatible: 1
supports(FEATURE_SET_COMPUTE_10): 1
supports(FEATURE_SET_COMPUTE_11): 1
supports(FEATURE_SET_COMPUTE_12): 1
supports(FEATURE_SET_COMPUTE_13): 1
supports(FEATURE_SET_COMPUTE_20): 1
supports(FEATURE_SET_COMPUTE_21): 1
supports(FEATURE_SET_COMPUTE_30): 1
supports(FEATURE_SET_COMPUTE_32): 1
supports(FEATURE_SET_COMPUTE_35): 1
supports(FEATURE_SET_COMPUTE_50): 1
supports(FEATURE_SET_COMPUTE_52): 1
supports(FEATURE_SET_COMPUTE_60): 1
supports(FEATURE_SET_COMPUTE_61): 1
supports(FEATURE_SET_COMPUTE_70): 0
OpenCV(3.4.1) Error: Gpu API call (invalid configuration argument) in cv::cudev::grid_transform_detail::TransformDispatcher<true, Policy>::call, file c:\opencv3_20180329\opencv-3.4.1\modules\cudev\include\opencv2\cudev\grid\detail/transform.hpp, line 318
Error: OpenCV(3.4.1) c:\opencv3_20180329\opencv-3.4.1\modules\cudev\include\opencv2\cudev\grid\detail/transform.hpp:318: error: (-217) invalid configuration argument in function cv::cudev::grid_transform_detail::TransformDispatcher<true, Policy>::call

This is the code I am using.

#include <iostream>
#include "opencv2/opencv.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/cudaimgproc.hpp"
#include "opencv2/cudaarithm.hpp"

int main(int argc, char* argv[])
{
    std::cout << "\nCUDA with OPENCV test program";

    int cudaDevices = cv::cuda::getCudaEnabledDeviceCount();;
    if (cudaDevices > 0)
    {
        std::cout << "\n<" << cudaDevices << "> CUDA device(s) found" << std::endl;
        for (int i_device = 0; i_device < cudaDevices; i_device++)
        {
            cv::cuda::DeviceInfo info(i_device);
            std::cout <<
                "[CUDA Device " << i_device << "]" << std::endl <<
                "name: " << info.name() << std::endl <<
                "majorVersion: " << info.majorVersion() << std::endl <<
                "minorVersion: " << info.minorVersion() << std::endl <<
                "multiProcessorCount: " << info.multiProcessorCount() << std::endl <<
                "maxThreadsPerMultiProcessor: " << info.maxThreadsPerMultiProcessor() << std::endl <<
                "maxThreadsPerBlock: " << info.maxThreadsPerBlock() << std::endl <<
                "sharedMemPerBlock: " << info.sharedMemPerBlock() << std::endl <<
                "freeMemory: " << info.freeMemory() << std::endl <<
                "totalMemory: " << info.totalMemory() << std::endl <<
                "isCompatible: " << info.isCompatible() << std::endl <<
                "supports(FEATURE_SET_COMPUTE_10): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_10) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_11): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_11) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_12): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_12) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_13): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_13) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_20): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_20) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_21): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_21) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_30): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_30) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_32): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_32) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_35): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_35) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_50): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_50) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_52): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_52) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_60): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_60) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_61): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_61) << std::endl <<
                "supports(FEATURE_SET_COMPUTE_70): " << info.supports(cv::cuda::FEATURE_SET_COMPUTE_70) << std::endl;
        }
    }
    else
        std::cout << "\nCUDA not enabled on this machine";

    cv::cuda::setDevice(0);

    try
    {
        cv::Mat src_host = cv::imread("lena.png", cv::IMREAD_GRAYSCALE);
        cv::cuda::GpuMat dst, src;
        src.upload(src_host);

        cv::cuda::threshold(src, dst, 128.0, 255.0, cv::THRESH_BINARY);

        cv::Mat result_host;
        dst.download(result_host);
        //cv::imshow("Result", result_host);
        //cv::waitKey();
    }
    catch (const cv::Exception& ex)
    {
        std::cout << "Error: " << ex.what() << std::endl;
    }
    return 0;
}