How to check if OpenCV was compiled with TBB, CUDA or Qt support? How to check if OpenCV was compiled with TBB, CUDA or Qt support? windows windows

How to check if OpenCV was compiled with TBB, CUDA or Qt support?


You can know it by opening a python3 REPL in cmdline:

python3

Then importing opencv:

import cv2

Then printing build information:

print(cv2.getBuildInformation())

And look for CUDA and related GPU information.


following up on dpetrini's answer, You can add whatever support to want to regex search in this to pretty-fy the outputs, instead of searching for it in the build-info outputs.

import cv2import recv_info = [re.sub('\s+', ' ', ci.strip()) for ci in cv2.getBuildInformation().strip().split('\n')                if len(ci) > 0 and re.search(r'(nvidia*:?)|(cuda*:)|(cudnn*:)', ci.lower()) is not None]print(cv_info)
['NVIDIA CUDA: YES (ver 10.0, CUFFT CUBLAS FAST_MATH)', 'NVIDIA GPU arch: 75', 'NVIDIA PTX archs:', 'cuDNN: YES (ver 7.6.5)']


If OpenCV is compiled with CUDA capability, it will return non-zero for getCudaEnabledDeviceCount function (make sure you have CUDA installed). Another very simple way is to try using a GPU function in OpenCV and use try-catch. If an exception is thrown, you haven't compiled it with CUDA.