gpt4 book ai didi

python-2.7 - OpenCV 3.2 CUDA 支持 python

转载 作者:太空宇宙 更新时间:2023-11-03 20:47:48 25 4
gpt4 key购买 nike

我刚刚按照 http://www.pyimagesearch.com/2016/07/11/compiling-opencv-with-cuda-support/ 中的说明安装了支持 CUDA 的 OpenCV 3.2。我只是想知道如何在运行时检查我的 OpenCV 是否使用 CUDA 和 GPU 支持(我使用 python2.7)

最佳答案

正如您在 link you gave 中看到的那样,您可以随时检查是否已安装 CUDA通过在 python 上输入正确控制台。

print(cv2.getBuildInformation())

如果你有 CUDA 支持,你会看到 Use CUDA: YES (version)在打印文本中。

然后你可以使用 opencv cuda cv2.cuda 中的命令模块。

但正如该教程中所述 CUDA python 目前不支持。 (由于这些教程在 OpenCV python 上,您会感到困惑,这是否会添加 CUDApython 的支持。但它 不会..)

Furthermore, in a GPU-enabled CUDA environment, there are a number of compile-time optimizations we can make to OpenCV, allowing it to take advantage of the GPU for faster computation (but mainly for C++ applications, not so much for Python, at least at the present time).

但如this answer中所述, 你可以得到 OpenCL支持 python。如 this文档,

Open Computing Language (OpenCL) is an open standard for writing code that runs across heterogeneous platforms including CPUs, GPUs, DSPs and etc.

编辑 1:

你可以做的另一件事是,你可以写python每个 GPU 的 wrapper OpenCV C++ 中的方法并通过 python 调用这些方法.我不建议这样做,因为这将始终在 GPU 之间复制图像和其他数据。内存和 RAM导致性能不佳。有时这会花费比 CPU 更多的时间一个人。

您可以做的另一件事是使用 GPU 编写您需要执行的整个函数。在 C++并写一个 python该函数的包装器。这比以前的方法好得多,但您需要知道 C++ .

可以有更好的方法来做到这一点..

关于python-2.7 - OpenCV 3.2 CUDA 支持 python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43315483/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com