问题描述
我刚刚按照 http://www.pyimagesearch.com/2016/07/11/compiling-opencv-with-cuda-support/我只是想知道如何在运行时检查我的OpenCV是否使用CUDA和GPU支持(我使用python2.7)
I've just installed OpenCV 3.2 compiling with CUDA support following instruction in http://www.pyimagesearch.com/2016/07/11/compiling-opencv-with-cuda-support/I just wonder how to check whether my OpenCV is using CUDA and GPU support when running (I use python2.7)
推荐答案
如您在链接,您始终可以通过在python
控制台上键入此链接来检查是否已正确安装CUDA
.
As you can see in the link you gave, you can always check whether you have installed CUDA
correctly by typing this on python
console.
print(cv2.getBuildInformation())
如果您具有CUDA支持,则会在打印的文本中看到Use CUDA: YES (version)
.
If you have CUDA support, you will be seen that Use CUDA: YES (version)
in the printed text.
但是正如该教程中所述,CUDA
目前在python中不提供支持. (由于这些教程位于OpenCV python
上,因此您是否会为python
增加CUDA
支持会感到困惑.但是 不会. ))
But as said in that tutorial CUDA
support is not there at present in python. (As these tutorials are on OpenCV python
you will get confused whether this will add CUDA
support for python
. But it will not..)
但是,如此答案中所述,您可以获得python上的OpenCL
支持.如此文档
But as described in this answer, you can get OpenCL
support on python. As in this document,
您可以做的另一件事是,您可以为OpenCV C++
中的每个GPU
方法编写python
包装器,然后通过python
调用这些方法.我不建议这样做,因为这将始终在GPU
内存和RAM
之间复制图像和其他数据,从而导致性能下降.有时,这将比单独使用CPU
花费更多的时间.
Another thing that you can do is, you can write python
wrappers for each GPU
methods in OpenCV C++
and call those methods via python
. I will not recommend that because this will always copy images and other data between GPU
memory and RAM
resulting bad performance. Sometimes this will take more time than CPU
alone.
您可以做的另一件事是使用C++
中的GPU
编写所需完成的整个函数,并为该函数编写一个python
包装器.这比以前的方法要好得多,但是您需要了解C++
.
Another thing that you can do is writing the whole function you need to do using GPU
in C++
and write a python
wrapper for that function. This is much more better than the previous method but you will need to know C++
.
可能会有更好的方法.
这篇关于OpenCV 3.2 CUDA支持python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!