Opencv DNN c++ GPU issue

My YOLOv8 model is trained on RTX 4090 using Ultralytics. I exported it to ONNX. And when I use the model using opencv DNN in C++ for inference on any other GPU than 4090 (4060, A6000) I do not have good accuracy. The same works perfectly fine on any 4090 system. I am using this for inference: ultralytics/examples/YOLOv8-CPP-Inference/inference.cpp at main · ultralytics/ultralytics

This is the error I am getting
C:\Users\Admin\Code\opencv_cuda\opencv\modules\dnn\src\cuda4dnn\csl\cudnn/convolution.hpp:303: error: (-217:Gpu API call) cuDNN did not return a suitable algorithm for convolution. in function ‘cv::dnn::cuda4dnn::csl::cudnn::ConvolutionAlgorithm::ConvolutionAlgorithm’