Skip to content

Forward input on cuda device crash #16869

@stereomatchingkiss

Description

@stereomatchingkiss
System information (version)
  • OpenCV => 4.3.0(448a545)
  • Operating System / Platform => Windows 64 Bit
  • Compiler => Visual Studio 2017 64 bits
  • Cuda => 10.1
Detailed description

Forward the input data on cpu work, but fail on gpu. Details can find in the issue #16476

Link of the model

Steps to reproduce
#include <opencv2/core.hpp>
#include <opencv2/dnn.hpp>

#include <iostream>

using namespace std;

void switch_to_cuda(cv::dnn::Net &net)
{
    for(auto const &vpair : cv::dnn::getAvailableBackends()){
        if(vpair.first == cv::dnn::DNN_BACKEND_CUDA && vpair.second == cv::dnn::DNN_TARGET_CUDA){
            net.setPreferableBackend(cv::dnn::DNN_BACKEND_CUDA);
            net.setPreferableTarget(cv::dnn::DNN_TARGET_CUDA);
            cout<<__func__<<":can switch to cuda"<<endl; //can switch to cuda
            break;
        }
    }
}

int main()
{
    cv::Mat input(128, 256, CV_32FC3);
    auto blob = cv::dnn::blobFromImage(input);
    cout<<__func__<<":blob get"<<endl;

    cout<<__func__<<":set input"<<endl;
    auto net = cv::dnn::readNetFromONNX("osnet_ain_x1_0.onnx");

    //switch_to_cuda(net); //crash if switch to cuda

    net.setInput(blob);
    cout<<__func__<<":forward"<<endl;
    net.forward();
    cout<<__func__<<":forward done"<<endl;

    std::cout<<__func__<<":forward done"<<std::endl;

    return 0;
}

Not error messages, guess there are some layers not supported by cuda yet?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions