2

I am on Windows 10, using Python 3.9.6 and my cv2 version is 4.4.0. I built OpenCV with Cuda successfully and after calling cv2.cuda.getCudaEnabledDeviceCount(), it returns 1 as expected. The following lines also work fine.

net = cv2.dnn.readNetFromCaffe(proto_file, weights_file)
net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)

# multiple lines
# processing frame
# and setting input blob

net.setInput(in_blob)

However, executing the following line throws an exception.

output = net.forward()

The exception:

cv2.error: OpenCV(4.4.0) G:\opencv-4.4.0\opencv-4.4.0\modules\dnn\src\dnn.cpp:2353: error: (-216:No CUDA support) OpenCV was not built to work with the selected device. Please check CUDA_ARCH_PTX or CUDA_ARCH_BIN in your build configuration. in function 'cv::dnn::dnn4_v20200609::Net::Impl::initCUDABackend'

The message says that my Cuda was not built to work with the selected device (which I'm guessing is my GPU). It seems to have encountered a conflict with CUDA_ARCH_BIN and/or CUDA_ARCH_PTX. My GPU model is NVIDIA Geforce MX130 whose CUDA_ARCH_BIN value is what I found to be 6.1 and I set it according on CMake. How can I resolve these issues? Let me know if I need to provide any more information.

0

1 Answer 1

4

"Sources say" the MX130 has a Maxwell core, not a Pascal core. Maxwell is the predecessor of Pascal.

Hence, you only have CUDA compute capability 5.0.

You should check that with an appropriate tool such as GPU-Z that does its best to query the hardware instead of going by specs.

Sources:

Sign up to request clarification or add additional context in comments.

4 Comments

So, should I set CUDA_ARCH_BIN to 5.0? Why does it say 6.1 in most places? I'm a beginner when it comes to GPU hardware specifications.
NVIDIA's website says Maxwell (5.x). I was unable to locate any website that indicates that MX130 has compute capability 6.1 (Pascal)
yes, in your place I'd try 5.0 now. I think it'll work. the defaults for OpenCV's CUDA modules compile for several compute capabilities, which is also why building OpenCV with CUDA enabled takes so long.
I rebuilt it by setting CUDA_ARCH_BIN to 5.0. It worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.