Reputation: 168
I am trying to work some image-process tasks with opencv on GPU with CUDA. I am using ubuntu. I setup my two products Opencv and Cuda without a problem, I am sure about that. However, when I attempt to run sampleCOde in eclipse, I have get an error:
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.
Upvotes: 8
Views: 32122
Reputation: 11
If anyone is facing the same issues when trying to run the notebook on 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
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.
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.
So here are all the steps I took to get OpenCV running on Google Colab with CUDA support.
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.
If you think, I missed something or something is incorrect, please let me know.
Upvotes: 1
Reputation: 11
I guess your system path is still set to previous dlls which are not compiled with gpu. You should first change your system path after the rebuilt of opencv.
Upvotes: 1
Reputation: 6615
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.
Don't know why that should matter but it did.
Upvotes: 1
Reputation: 2038
As stated in the documentation, you have to build OpenCV using CMake and set the flag WITH_CUDA=ON. Then you will get the full-featured OpenCV GPU module. Otherwise the module is still built, but you recieve an exception with CV_GpuNotSupported.
For further information, read here: http://docs.opencv.org/modules/gpu/doc/introduction.html
Upvotes: 7