Runtime error [no kernel image is available for execution on the device]

  • OpenCV => 3.4
  • Operating System / Platform => windows 10
  • Compiler => VS2019
  • GPU => 3090
  • CUDA version => 11.4
  • Driver version => 472.12
  • CUDA Capability => 8.6
Detailed description

I have no problem building Opencv 3.4 with CUDA, only the option I change is “WITH_NVCUVID” → off and CUDA_ARCH_BIN = 8.6.
Then, ALL_BUILD and INSTALL are all successful with on single error.

The strange thing is when I wrote a simple test code to call cv::cuda::resize.

	int CudaDevice;
	FILE* outfp1;
	outfp1 = fopen("GPU.txt", "w");
	if (cv::cuda::getCudaEnabledDeviceCount() == 0)
		fprintf(outfp1, "NO CUDA\n");
		fprintf(outfp1, "CUDA = %d\n", cv::cuda::getCudaEnabledDeviceCount());
		CudaDevice = cv::cuda::getDevice();
	cv::Mat inImage = cv::imread("test.jpg");
	cv::Mat outImage;
	cv::cuda::GpuMat gpuInImage;
	cv::cuda::GpuMat gpuOutImage;
	cv::cuda::resize(gpuInImage, gpuOutImage, cv::Size(), 0.5, 0.5, cv::INTER_LINEAR);;
	imwrite("output_gpu.jpg", outImage);

I can get a cuda device, and the index is 0.
It came out a error said “OpenCV Error: Gpu API call (no kernel image is available for execution on the device) in cv::cuda::device::call_resize_linear_glob”

It came from cudaSafeCall( cudaGetLastError() ), and I don’t no what I miss the procedure. Can anyone give me some instructions?

That is odd, maybe its a 3.4 issue. If it was me I would check the values returned inside
isDeviceCompatible() as I described here.


Thanks for your kind reply.

I tried to change things below, and it works!! Error is solved.

  1. In Cmake, set CUDA_ARCH_BIN 5.0, 5.2, 6.0, 6.1, 7.0, 7.5, 8.6
  2. In VS, setting code generation change to “compute_60, sm_60”

To be honest, I’m not sure why I can’t use computation capability 8.6, maybe it’s opencv3.4’s problem.