Ask Your Question
0

OpenCV CUDA backend

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

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

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:

 cmake -D CMAKE_BUILD_TYPE=RELEASE 
-D CMAKE_INSTALL_PREFIX=/usr/local 
-D OPENCV_EXTRA_MODULES_PATH=~/opencv-4.2.0/opencv_contrib/modules 
-D OPENCV_ENABLE_NONFREE=ON 
-D BUILD_NEW_PYTHON_SUPPORT=ON 
-D INSTALL_PYTHON_EXAMPLES=ON 
-D OPENCV_FORCE_PYTHON_LIBS=ON 
-D PYTHON3_EXECUTABLE=~/anaconda3/envs/yolo-gpu/bin/python
-D PYTHON3_LIBRARY=~/anaconda3/envs/yolo-gpu/lib/libpython3.6m.so
-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 WITH_CUDA=ON 
-D BUILD_opencv_cudacodec=OFF 
-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-10.0 
-D CUDA_ARCH_BIN=5.3 -D CUDA_ARCH_PTX=5.3 
-D BUILD_EXAMPLES=ON ..

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

Comments

Please use OpenCV 4.3. All devices are supported now.

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

1 answer

Sort by ยป oldest newest most voted
0

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

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

-DOPENCV_DNN_CUDA=OFF

and compile for your arch

-DCUDA_ARCH_BIN=5.0 -DCUDA_ARCH_PTX=5.0

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

Comments

All devices are supported since OpenCV 4.3.

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

Question Tools

1 follower

Stats

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

Seen: 6,360 times

Last updated: Apr 28 '20