CUDA Application launches with a delay while using OpenCV 3.1.0


I have two applications running in different environments (Windows, Linux) both meeting the same problems when starting CUDA processing using OpenCV GPU functions.

The problem appears during the first call to GpuMat - program “hangs” for about 10 seconds, then it works normally. I’ve tested it on Linux and Windows on GTX 960 and 980, but it works fine on older GTX 570.

OpenCV 3.1.0 was compiled with the default settings in all cases.

It may be a JIT compile issue. If your OpenCV/GpuMat libraries were compiled with -arch=sm_20 (but not -arch=sm_52) then they will contain the correct binaries for the GTX570 but not for the GTX960/980. JIT compile at runtime would then be triggered to provide the necessary GPU code for GTX960/980, and this would be done for all the GPU kernels in the library.

Normally there is a JIT-cache so that this only happens once, but it’s possible that the cache is too small or it is disabled.

Try rebuilding the OpenCV GPU libraries with the correct architecture switches to match the GPU you will actually run on.