本文介绍了OpenCV 3.2 CUDA支持python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚按照 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 00:45