Tag Archives: linux+opencv+cuvid

[record a problem] Linux + opencv + cuvid decodes 1080p video. When using CUDA kernel function, it will crash

Explain the function of static keyword and final keyword in Java in detail>>>

The information about the crash is as follows:

1 OpenCV(4.1.0-dev) Error: Gpu API call (invalid configuration argument) in videoDecPostProcessFrame, file /home/admin/opencv/opencv_contrib-master/modules/cudacodec/src/cuda/nv12_to_rgb.cu, line 203
2 terminate called after throwing an instance of 'cv::Exception'
3   what():  OpenCV(4.1.0-dev) /home/admin/opencv/opencv_contrib-master/modules/cudacodec/src/cuda/nv12_to_rgb.cu:203: error: (-217:Gpu API call) invalid configuration argument in function 'videoDecPostProcessFrame'
4 
5 Aborted (core dumped)

The strange points are as follows:
1. The same program decodes 720p video/480p video and calls CUDA kernel function for further processing

2. 1080p video decodes the first frame and calculates it. It is normal

3. Write an empty kernel function, nothing is bad. 1080p video still has errors when decoding the second frame
it seems that it is not my own code pot, which can only be solved by submitting it to opencv team

==================================

Added at 15:00 on May 16, 2019, the problem has been solved

The key problem is that there are too many threads in the kernel function. I changed the code as follows:

1     if (rows>500){
2         _hsv_cacl_hist<<<1, rows/2>>>(data, cols, rows/2, step, channels, (uint32_t*)out->hist);
3         _hsv_cacl_hist<<<1, rows/2>>>(data+step*(rows/2), cols, rows/2, step, channels, (uint32_t*)out->hist);
4     } else {
5         _hsv_cacl_hist<<<1, rows>>>(data, cols, rows, step, channels, (uint32_t*)out->hist);
6     }

The above code solves the problem of crash

But the strange thing is, why not crash in this function, but in video decoding