Ask Your Question

OpenCV CUDA backend

asked 2020-04-28 09:21:07 -0500

updated 2020-04-28 10:26:58 -0500

berak gravatar image

Hey all!
I have a question: can I use OpenCV 4.2.0 with CUDA backend on device with 5.0 capability? It's support? Or only 5.3 and more supported?
Now after compile and run code I have an error:

OpenCV Error: Gpu API call (invalid device function)

When I try to set CUDA_ARCH_BIN=5.0 in CMake options, its doesnt compile with error:

CUDA backend for DNN module requires CC 5.3 or higher. Please remove unsupported architectures from CUDA_ARCH_BIN option

When I try to set CUDA_ARCH_BIN="5.3 6.0 6.1 7.0 7.5" and CUDA_GENERATION=Auto in CMake options, its doesnt compile with the same error.

My current options:

-D OPENCV_EXTRA_MODULES_PATH=~/opencv-4.2.0/opencv_contrib/modules 
-D PYTHON3_EXECUTABLE=~/anaconda3/envs/yolo-gpu/bin/python
-D PYTHON3_LIBRARY=~/anaconda3/envs/yolo-gpu/lib/
-D PYTHON3_INCLUDE_DIRS=~/anaconda3/envs/yolo-gpu/include
-D PYTHON3_NUMPY_INCLUDE_DIRS=~/anaconda3/envs/yolo-gpu/lib/python3.6/site-packages/numpy 
-D BUILD_opencv_cudacodec=OFF 
-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-10.0 

Its compile but doesnt work.
What can I do?
CUDA 10.0, CUDNN 7.6, GeForce 940M with 5.0 compute capability.

edit retag flag offensive close merge delete


Please use OpenCV 4.3. All devices are supported now.

Yashas gravatar imageYashas ( 2020-05-23 03:19:51 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2020-04-28 11:28:50 -0500

If you build for compute-capability 5.3 then the resulting device code will not run on your 5.0 device. Additionally as far as I am aware the CUDA DNN backend is not supported on devices of compute-capability less than 5.3 (even in OpenCV 4.3.0 which will compile for these devices without the "CUDA backend for DNN module requires CC 5.3...." error).

If you want to access to all the CUDA functions except the DNN backend then I would disable it by passing


and compile for your arch


Alternatively upgrade to OpenCV 4.3.0 which will allow you to compile for "all" compute-capabilities, meaning that you could use the CUDA DNN module on newer cards with the same binary if you wanted.

edit flag offensive delete link more


All devices are supported since OpenCV 4.3.

Yashas gravatar imageYashas ( 2020-05-23 03:19:23 -0500 )edit

Question Tools

1 follower


Asked: 2020-04-28 09:21:07 -0500

Seen: 2,166 times

Last updated: Apr 28 '20