Issue 1:
System information (version)

OpenCV => 4.5.1

Operating System / Platform => Linux Ubuntu18.04

Compiler => g++ 7.4.0

CUDA => 10.0

cudnn => 7.6.3

GPU=> GTX1080

Detailed description

I use opencv dnn(gpu) to load onnx face detection model (centerface) for inference, The time used for single reasoning on GTX1080 is 100ms , cpu time About 40 ms， （image size 480*640）

My cmake config:

cmake -D CMAKE_BUILD_TYPE=RELEASE

-D CMAKE_INSTALL_PREFIX=/usr/local

-D INSTALL_PYTHON_EXAMPLES=ON

-D INSTALL_C_EXAMPLES=OFF

-D OPENCV_ENABLE_NONFREE=ON

-D WITH_CUDA=ON

-D WITH_CUDNN=ON

-D OPENCV_DNN_CUDA=ON

-D ENABLE_FAST_MATH=1

-D CUDA_FAST_MATH=1

-D CUDA_ARCH_BIN=6.1

-D WITH_CUBLAS=1

-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules

-D BUILD_opencv_python2=OFF

-D BUILD_opencv_python3=ON

-D PYTHON_DEFAULT_EXECUTABLE=${VIRTUAL_PYTHON_PATH}/bin/python3

-D PYTHON3_EXCUTABLE=${VIRTUAL_PYTHON_PATH}/bin/python3

-D PYTHON3_LIBRARY=${VIRTUAL_PYTHON_PATH}/lib/lib${PYTHON_VERSION}m.so.1.0

-D PYTHON_NUMPY_PATH=${VIRTUAL_PYTHON_PATH}/lib/${PYTHON_VERSION}/site-packages

-D BUILD_EXAMPLES=ON ../

Steps to reproduce

import cv2
import time
import numpy as np

def transform(h, w):
img_h_new, img_w_new = int(np.ceil(h / 32) * 32), int(np.ceil(w / 32) * 32)
scale_h, scale_w = img_h_new / h, img_w_new / w
return img_h_new, img_w_new, scale_h, scale_w

if __name__ == "__main__":
onnx_path = "centerface.onnx"
net = cv2.dnn.readNetFromONNX(onnx_path)
if cv2.cuda.getCudaEnabledDeviceCount():
net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)

img_path = "test.jpg"
img = cv2.imread(img_path)
height, width, _ = img.shape
img_h_new, img_w_new, scale_h, scale_w = transform(height, width)

blob = cv2.dnn.blobFromImage(img, scalefactor=1.0, size=(img_w_new, img_h_new), mean=(0, 0, 0), swapRB=True, crop=False)
net.setInput(blob)
for i in range(50):
begin=time.time()
heatmap, scale, offset, lms = net.forward(["537", "538", "539", '540'])
print("infer times = ", time.time() - begin)

test [onnx model] (https://github.com/Star-Clouds/CenterFace/tree/master/models/onnx/centerface.onnx)

test picture ：any picture , maybe use time is different, but the use time ratio is the same

Issue submission checklist

I report the issue, it's not a question

I checked the problem with documentation, FAQ, open issues,

forum.opencv.org, Stack Overflow, etc and have not found solution

I updated to latest OpenCV version and the issue is still there

There is reproducer code and related data files: videos, images, onnx, etc

Issue 2:
System information (version)

OpenCV => 4.5.0

Operating System / Platform => Linux

Detailed description

I'm getting FPS: 10-12 using DNN with CPU. But when I use DNN with CUDA then I'm getting FPS 1-2.

Using DNN with CUDA by following code:

NET = cv2.dnn.readNetFromCaffe(
"model/ssd/MobileNetSSD.prototxt",
"model/ssd/MobileNetSSD.caffemodel")
NET.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
NET.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)

Also my cmake conf are as follows:

PREFIX_MAIN=`pyenv virtualenv-prefix`
PREFIX=`pyenv prefix`

cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D WITH_CUDA=ON \
-D CUDA_ARCH_PTX="" \
-D CUDA_ARCH_BIN="5.3,6.2,7.2" \
-D WITH_CUBLAS=ON \
-D WITH_LIBV4L=ON \
-D BUILD_opencv_python3=ON \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_java=OFF \
-D WITH_GSTREAMER=ON \
-D WITH_GTK=ON \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D CUDA_FAST_MATH=ON \
-D ENABLE_NEON=ON \
-D OPENCV_DNN_CUDA=ON \
-D WITH_CUDNN=ON \
-D WITH_OPENGL=ON \
-D CMAKE_INSTALL_PREFIX="$PREFIX" \
-D PYTHON3_EXECUTABLE="$PREFIX"/bin/python3 \
-D PYTHON3_PACKAGES_PATH="$PREFIX"/lib/python3.7/site-packages \
-D PYTHON3_LIBRARY="$PREFIX_MAIN"/lib/libpython3.7m.a \
-D PYTHON3_INCLUDE_DIR="$PREFIX_MAIN"/include/python3.7m \
-D OPENCV_EXTRA_MODULES_PATH=/home/jetson-tx2-2/tmp/opencv_contrib/modules ..

There were no errors during build and installation.

I don't know what's the reason for such low FPS with CUDA. I've searched for solutions but failed. Please let me know if there is any issue with opencv 4.5.0.

Other necessary info:

Jetpack: 4.3

NVIDIA CUDA: YES (ver 10.0, CUFFT CUBLAS FAST_MATH)
NVIDIA GPU arch: 53 62 72
NVIDIA PTX archs:

cuDNN: YES (ver 7.6.3)