[英]Opencv Error: no GPU support (library is compiled without CUDA support)
I am trying to work some image-process tasks with opencv on GPU with CUDA.我正在尝试使用 CUDA 在 GPU 上使用 opencv 处理一些图像处理任务。 I am using ubuntu.我正在使用 ubuntu。 I setup my two products Opencv and Cuda without a problem, I am sure about that.我毫无问题地设置了我的两个产品 Opencv 和 Cuda,我对此很确定。 However, when I attempt to run sampleCOde in eclipse, I have get an error:但是,当我尝试在 Eclipse 中运行 sampleCOde 时,出现错误:
OpenCV Error: No GPU support (The library is compiled without CUDA support) in mallocPitch, file /home/muad/Source/OpenCV-2.4.2/modules/core/src/gpumat.cpp, line 749
I remade my opencv, but I still get that.我重新制作了我的opencv,但我仍然明白。
As stated in the documentation, you have to build OpenCV using CMake and set the flag WITH_CUDA=ON.如文档中所述,您必须使用 CMake 构建 OpenCV 并设置标志 WITH_CUDA=ON。 Then you will get the full-featured OpenCV GPU module.然后您将获得功能齐全的 OpenCV GPU 模块。 Otherwise the module is still built, but you recieve an exception with CV_GpuNotSupported.否则,该模块仍会构建,但您会收到 CV_GpuNotSupported 的异常。
For further information, read here: http://docs.opencv.org/modules/gpu/doc/introduction.html欲了解更多信息,请阅读此处: http ://docs.opencv.org/modules/gpu/doc/introduction.html
I had the same problem.我有同样的问题。 I fixed it by copying opencv_core243d.dll from E:\opencv\build\gpu\x64\vc10\lib
folder to the work directory with the .exe.我通过将 opencv_core243d.dll 从E:\opencv\build\gpu\x64\vc10\lib
文件夹复制到带有 .exe 的工作目录来修复它。 Don't know why that should matter but it did.不知道为什么这很重要,但确实如此。
I guess your system path is still set to previous dlls which are not compiled with gpu.我猜你的系统路径仍然设置为以前没有用 gpu 编译的 dll。 You should first change your system path after the rebuilt of opencv.您应该在重建 opencv 后首先更改您的系统路径。
If anyone is facing the same issues when trying to run the notebook on Google Colab.如果有人在尝试在 Google Colab 上运行笔记本时遇到同样的问题。 Then here is how I resolved it.然后这就是我解决它的方法。
I tried out many things and came across this blog : https://towardsdatascience.com/how-to-use-opencv-with-gpu-on-colab-25594379945f我尝试了很多东西,发现了这个博客: https ://towardsdatascience.com/how-to-use-opencv-with-gpu-on-colab-25594379945f
The blog describes how to build, OpenCV with CUDA support and then place the final build file (*.so) into the Colab working directory to be accessed and run OpenCV through it.该博客描述了如何构建具有 CUDA 支持的 OpenCV,然后将最终构建文件 (*.so) 放入 Colab 工作目录以进行访问并通过它运行 OpenCV。
Even though I got all the steps done, the issues were not resolved, because Colab has pre-installed OpenCV, which needs to be removed before you can use the compiled build version.尽管我完成了所有步骤,但问题并没有解决,因为 Colab 已经预先安装了 OpenCV,需要先将其删除,然后才能使用编译后的构建版本。
So here are all the steps I took to get OpenCV running on Google Colab with CUDA support.以下是我在支持 CUDA 的 Google Colab 上运行 OpenCV 所采取的所有步骤。
import cv2
cv2.__version__
%cd /content
!git clone https://github.com/opencv/opencv
!git clone https://github.com/opencv/opencv_contrib
!mkdir /content/build
%cd /content/build
!cmake -DOPENCV_EXTRA_MODULES_PATH=/content/opencv_contrib/modules -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_EXAMPLES=OFF -DWITH_OPENEXR=OFF -DWITH_CUDA=ON -DWITH_CUBLAS=ON -DWITH_CUDNN=ON -DOPENCV_DNN_CUDA=ON /content/opencv
!make -j8 install
!mkdir "/content/drive/MyDrive/"
!cp -R /content/build "/content/drive/MyDrive/"
!pip uninstall opencv-python
!cp "/content/drive/MyDrive/build/lib/python3/cv2.cpython-37m-x86_64-linux-gnu.so" .
That's all.就这样。 Make sure to make appropriate changes in the file path if you are using some other location when copying the files from and to the google drive.如果在将文件从 Google 驱动器复制到 google 驱动器时使用其他位置,请确保对文件路径进行适当的更改。
If you think, I missed something or something is incorrect, please let me know.如果您认为我遗漏了某些内容或某些内容不正确,请告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.