error: (-217) invalid resource handle in function call while using setDevice

asked 2018-02-23 15:45:21 -0600

gegupta gravatar image

I currently have a machine with 4 GPUs and i am trying out my program to use more than one device. But if i use any device other than 0, i get following error. Can someone help in knowing why i might be getting it and how can i resolve it.

GPU #2 (Tesla P100-PCIE-16GB) OpenCV Error: Gpu API call (invalid resource handle) in call, file /home/gegupta/opencv/modules/cudawarping/src/cuda/resize.cu, line 438 Error: /home/gegupta/opencv/modules/cudawarping/src/cuda/resize.cu:438: error: (-217) invalid resource handle in function call

Code :

    Stream stream;
    setDevice(2);
    std::cout << "GPU #" << DeviceInfo().deviceID() << " (" << DeviceInfo().name()<< ")\n";
    cv::Mat::setDefaultAllocator(cv::cuda::HostMem::getAllocator (cv::cuda::HostMem::AllocType::PAGE_LOCKED));

    Mat src = imread(input_file,CV_LOAD_IMAGE_COLOR);
    if(!src.data){
            std::cout<<"Image Not Found: "<< input_file << std::endl;
            return;
    }

    cuda::GpuMat d_src;
    d_src.upload(src,stream);
    cuda::GpuMat d_dst;

    cuda::resize(d_src, d_dst, Size(400, 400),0,0, CV_INTER_AREA,stream);

    Mat dst;
    d_dst.download(dst,stream);

Test Machine configuration:

4 GPU (Tesla P100) - but test only utilizes 1 GPU

64 CPU cores (over Intel Xeon 2680 v4 CPU )

OpenCV version : 3.4.0

Cuda Toolkit : 9.0

I saw another post but no answer : https://github.com/opencv/opencv/issu...

edit retag flag offensive close merge delete