Reputation: 5978
How can I find out whether OpenCV library was compiled with TBB or CUDA or QT on Windows 7 machine? Should I use dependency walker, and if so, how? Or is there another way to find out?
Upvotes: 21
Views: 26464
Reputation: 41
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 cv2
import re
cv_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)']
Upvotes: 4
Reputation: 1239
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.
Upvotes: 16
Reputation: 360
bool _cudaSupported = false;
...
// Obtain information from the OpenCV compilation
// Here is a lot of information.
const cv::String str = cv::getBuildInformation();
// Parse looking for "Use Cuda" or the option you are looking for.
std::istringstream strStream(str);
std::string line;
while (std::getline(strStream, line))
{
// Enable this to see all the options. (Remember to remove the break)
//std::cout << line << std::endl;
if(line.find("Use Cuda") != std::string::npos)
{
// Trim from elft.
line.erase(line.begin(), std::find_if(line.begin(), line.end(),
std::not1(std::ptr_fun<int, int>(std::isspace))));
// Trim from right.
line.erase(line.begin(), std::find_if(line.begin(), line.end(),
std::not1(std::ptr_fun<int, int>(std::isspace))));
// Convert to lowercase may not be necessary.
std::transform(line.begin(), line.end(), line.begin(), ::tolower);
if (line.find("yes") != std::string::npos)
{
std::cout << "USE CUDA = YES" << std::endl;
_cudaSupported = true;
break;
}
}
}
Upvotes: 0
Reputation: 3639
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.
Upvotes: 2
Reputation: 6420
For CUDA support you can check gpu module size. If OpenCV is compiled without CUDA support, opencv_gpu.dll will have small size (< 1 MB), it will be a dummy package. The real size of gpu module built with CUDA support is ~ 70 MB for one compute capability.
Upvotes: 1