0

So, I'm trying to install openCV with GPU support on my laptop via cmake. I followed every single step from https://thinkinfi.com/install-opencv-gpu-with-cuda-for-windows-10/ and other tutorials from youtube, and cmake wasn't able to find some Python 3 parameters including Interpreters, Libraries, numpy, and install path. I have tried reinstalling all necessary software from beginning and tried others solution but none of them worked.

To make everything clear, I'll briefly explain what I have done.

  1. Installing anaconda, cmake, VS code 16 2019, CUDA, and cuDNN
  2. Download opencv-4.8.0 and opencv_contrib-4.8.0 from github
  3. Create a build folder inside a folder called "opencv_gpu" which contains: opencv-4.8.0 and opencv_contrib-4.8.0
  4. Configure on cmake with opencv-4.8.0 as the source code and VS code 16 2019 as the generator
  5. Checking unchecked parameters including WITH_CUDA, OPENCV_DNN_CUDA, ENABLE_FAST_MATH, and set the path for OPENCV_EXTRA_MODULES_PATH to D:\opencv_gpu\opencv_contrib-4.8.0\modules
  6. Configure again then check CUDA_FAST_MATH, set CMAKE_CONFIGURATION_TYPES to only Release, and CUDA_ARCH_BIN to 8.6 (My GPU is NVIDIA RTX 3050 and its compute capability is 8.6) you can check here https://en.wikipedia.org/wiki/CUDA
  7. Configure -> Generate
  8. Run this command cmake --build "D:\opencv_gpu\build" --target INSTALL --config Release
  9. Done

This is the warning message I get in every configuration which I believe leads to the error message below

  Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
  are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning.

Call Stack (most recent call first):
  cmake/OpenCVDetectPython.cmake:64 (find_host_package)
  cmake/OpenCVDetectPython.cmake:280 (find_python)
  CMakeLists.txt:649 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

and when I try to import cv2 this is the error that it gives (This is done after the whole process)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2'

It should produce something like this after the configuration :

.
.
.
--  OpenCl:                         YES(NVD3D11)
--    Include path:                 D:/opencv_gpu/opencv-4.8.0/3rdparty/i
--    Link libraries:               Dynamic load

--   Python 3:
--     Interpreter:                 D:/anaconda3/python.exe (ver 3.10.9)
--     Libraries:                   {path to directory}
--     numpy:                       {path to directory}
--     packages path:               {path to directory}

--  Python (for build):             D:/anaconda3/python.exe
.
.
.

But this is what I get:

.
.
.
--  OpenCl:                         YES(NVD3D11)
--    Include path:                 D:/opencv_gpu/opencv-4.8.0/3rdparty/i
--    Link libraries:               Dynamic load

--  Python (for build):             D:/anaconda3/python.exe
.
.
.

Some other information:

Checking CUDA version to ensure that it's installed nvcc -V

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Wed_Jul_14_19:47:52_Pacific_Daylight_Time_2021
Cuda compilation tools, release 11.4, V11.4.100
Build cuda_11.4.r11.4/compiler.30188945_0

Some tutorials mention that this problem arises because of having older version of numpy. So I run the command and it seems like I have the latest version of numpy pip install --upgrade numpy

Requirement already satisfied: numpy in d:\anaconda3\lib\site-packages (1.25.1)
Dylan Mac
  • 55
  • 7
  • "This is the error message during configuration" - What you show is not an **error**, but a **warning**, which doesn't prevent the project to be configured. Please, show the error message. – Tsyvarev Jul 17 '23 at 15:33
  • @Tsyvarev I have modified the question, sorry for the mistake. – Dylan Mac Jul 17 '23 at 15:42
  • You write "cmake wasn't able to find some Python 3 parameters including Interpreters, Libraries, numpy, and install path" but **none** message you show is about such inability. Please, add to the question post the error message, which is about Python interpreter and other things. Also, do not post **images** of **text**; instead, copy paste corresponding messages into the post in the textual form. See https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors – Tsyvarev Jul 17 '23 at 15:57
  • "when I try to import cv2 this is the error that it gives (This is done after the configuration)" - For make OpenCV available for using, you need not only to **configure** OpenCV, but also **build** and **install** it. So, what **exact steps** have you performed? Please, list these steps directly in the question post, saying "I followed every single step from ..." is very vague. – Tsyvarev Jul 17 '23 at 16:04
  • @Tsyvarev Modified! please let me know if there's anything else I should change. Thank you :) – Dylan Mac Jul 17 '23 at 16:59
  • In the [official guide](https://docs.opencv.org/4.x/d5/de5/tutorial_py_setup_in_windows.html) they suggest also to check the `BUILD_opencv_python` option when configure the project. Have you checked this option in your case? They also have the following note "Since GPU modules are not yet supported by OpenCV-Python ...", but I don't know whether it is applicable for your case. – Tsyvarev Jul 17 '23 at 17:48
  • @Tsyvarev Yes, it's already checked by default – Dylan Mac Jul 18 '23 at 02:21

0 Answers0