Thank you so much for this. I have been trying to install opencv with cuda for a few days now and there was always some new error that I could not resolve. This is the first tutorial that worked without any issues. Thank you so much!!
It doesn't show the specific python paths in CMake for me, just the build. After adding them manually, the CMake installation just stops after 30-40 seconds and it didn't install the library, do these cases have anything in common or what could be the reason?
Great video. One question. If I have a virtual environment already developed, can I build the make file in the environment? Would I have to activate environment then follow your steps?
This is a copy and paste from a previous response Check if the line above "CUDA detected" (9:50) says Found CUDNN. If it says something like "Could NOT find CUDNN", you will have to manually point CMake to the correct files. 1) Install cuDNN, either from anaconda like at 2:50, or manually from NVIDIA (Just google cuDNN and follow NVIDIA's directions). 2) Click "Advanced" in CMake (Right next to the Search bar) 3) Search for CUDNN_LIBRARY and change the value. If you downloaded cuDNN from Anaconda, it will be something like C:/Users/YOUR_NAME/anaconda3/Library/lib/cudnn.lib if you downloaded from NVIDIA, it will be something like C:/Program Files/NVIDIA/CUDNN/v9.4/lib/12.6/x64/cudnn.lib (double check the directory because version numbers will likely be different for you). 4) Search for CUDNN_INCLUDE_DIR and change the value. If using Anaconda, it will be something like C:/Users/doyle/anaconda3/Library/include if using NVIDIA manually, it will be something like C:/Program Files/NVIDIA/CUDNN/v9.4/include/12.6 (Double check the version numbers, and if this doesn't work, try removing the directory after "include"). 5) Try running "Configure" again! cuDNN should now be findable by CMake!
CMake Error at modules/dnn/CMakeLists.txt:53 (message): DNN: CUDA backend requires cuDNN. Please resolve dependency or disable OPENCV_DNN_CUDA=OFF what is my fix for this?
Check if the line above "CUDA detected" (9:50) says Found CUDNN. If it says something like "Could NOT find CUDNN", you will have to manually point CMake to the correct files. 1) Install cuDNN, either from anaconda like at 2:50, or manually from NVIDIA (Just google cuDNN and follow NVIDIA's directions). 2) Click "Advanced" in CMake (Right next to the Search bar) 3) Search for CUDNN_LIBRARY and change the value. If you downloaded cuDNN from Anaconda, it will be something like C:/Users/YOUR_NAME/anaconda3/Library/lib/cudnn.lib if you downloaded from NVIDIA, it will be something like C:/Program Files/NVIDIA/CUDNN/v9.4/lib/12.6/x64/cudnn.lib (double check the directory because version numbers will likely be different for you). 4) Search for CUDNN_INCLUDE_DIR and change the value. If using Anaconda, it will be something like C:/Users/doyle/anaconda3/Library/include if using NVIDIA manually, it will be something like C:/Program Files/NVIDIA/CUDNN/v9.4/include/12.6 (Double check the version numbers, and if this doesn't work, try removing the directory after "include"). 5) Try running "Configure" again! cuDNN should now be findable by CMake!
cv2.error: OpenCV(4.8.0) D:\a\opencv-python\opencv-python\opencv\modules\core\include\opencv2/core/private.cuda.hpp:106: error: (-216:No CUDA support) The library is compiled without CUDA support in function 'throw_no_cuda' im getting this error after following your video, do you know of a fix?
@@HackersRealm I have the latest drivers and both cuda and cudnn are working when I use tensorflow and pytorch. Only when I try to use GPU with opencv I get the problems
How to fix this error please:CMake Error at modules/dnn/CMakeLists.txt:41 (message): DNN: CUDA backend requires cuDNN. Please resolve dependency or disable OPENCV_DNN_CUDA=OFF
i get: Could not find OpenBLAS include. Turning OpenBLAS_FOUND off Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off Could NOT find BLAS (missing: BLAS_LIBRARIES) Could NOT find LAPACK (missing: LAPACK_LIBRARIES) Reason given by package: LAPACK could not be found because dependency BLAS could not be found. Could NOT find Java (missing: Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE) Could NOT find JNI (missing: JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 AWT JVM) VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file Configuring incomplete, errors occurred! And an error pop up, when trying to "Generate"
Это не работает. Сборка CMake прошла успешно. Но импорт cv2 невозможен >>> import cv2 Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'cv2'
@@YetiRUS type "conda env list" in cmd to check the environment. then install the packages on the selected environment. If you don't have anaconda, please install it, as it will ease the process
Thank you so much for this. I have been trying to install opencv with cuda for a few days now and there was always some new error that I could not resolve. This is the first tutorial that worked without any issues. Thank you so much!!
glad it helps!!!
It doesn't show the specific python paths in CMake for me, just the build. After adding them manually, the CMake installation just stops after 30-40 seconds and it didn't install the library, do these cases have anything in common or what could be the reason?
My CMake is also having problems finding python, did you manage to solve it?
Great video. One question. If I have a virtual environment already developed, can I build the make file in the environment? Would I have to activate environment then follow your steps?
I think you can use on any environment once the installation process is done. It's like a global installation similar to microsoft vs build tools
Error in configuration process, project files may be invalid.
I'm getting this error after the process at 10 th minute
same anyone got a fix?
This is a copy and paste from a previous response
Check if the line above "CUDA detected" (9:50) says Found CUDNN. If it says something like "Could NOT find CUDNN", you will have to manually point CMake to the correct files.
1) Install cuDNN, either from anaconda like at 2:50, or manually from NVIDIA (Just google cuDNN and follow NVIDIA's directions).
2) Click "Advanced" in CMake (Right next to the Search bar)
3) Search for CUDNN_LIBRARY and change the value. If you downloaded cuDNN from Anaconda, it will be something like C:/Users/YOUR_NAME/anaconda3/Library/lib/cudnn.lib
if you downloaded from NVIDIA, it will be something like C:/Program Files/NVIDIA/CUDNN/v9.4/lib/12.6/x64/cudnn.lib (double check the directory because version numbers will likely be different for you).
4) Search for CUDNN_INCLUDE_DIR and change the value. If using Anaconda, it will be something like C:/Users/doyle/anaconda3/Library/include
if using NVIDIA manually, it will be something like C:/Program Files/NVIDIA/CUDNN/v9.4/include/12.6 (Double check the version numbers, and if this doesn't work, try removing the directory after "include").
5) Try running "Configure" again! cuDNN should now be findable by CMake!
I built opencv using cmake. but i can not import cv2 in anaconda prompt.
If anyone else is having issues make sure you are using visual studio 2019 for some reason the 2022 version doesnt work :0
I have just run into this issue, vs2019 is working fine.
CMake Error at modules/dnn/CMakeLists.txt:53 (message):
DNN: CUDA backend requires cuDNN. Please resolve dependency or disable
OPENCV_DNN_CUDA=OFF
what is my fix for this?
You have to install cuda drivers for your nvidia gpu
@@HackersRealm I have but still getting this error:(
Check if the line above "CUDA detected" (9:50) says Found CUDNN. If it says something like "Could NOT find CUDNN", you will have to manually point CMake to the correct files.
1) Install cuDNN, either from anaconda like at 2:50, or manually from NVIDIA (Just google cuDNN and follow NVIDIA's directions).
2) Click "Advanced" in CMake (Right next to the Search bar)
3) Search for CUDNN_LIBRARY and change the value. If you downloaded cuDNN from Anaconda, it will be something like C:/Users/YOUR_NAME/anaconda3/Library/lib/cudnn.lib
if you downloaded from NVIDIA, it will be something like C:/Program Files/NVIDIA/CUDNN/v9.4/lib/12.6/x64/cudnn.lib (double check the directory because version numbers will likely be different for you).
4) Search for CUDNN_INCLUDE_DIR and change the value. If using Anaconda, it will be something like C:/Users/doyle/anaconda3/Library/include
if using NVIDIA manually, it will be something like C:/Program Files/NVIDIA/CUDNN/v9.4/include/12.6 (Double check the version numbers, and if this doesn't work, try removing the directory after "include").
5) Try running "Configure" again! cuDNN should now be findable by CMake!
i can import cv2 but not have any module: __version__ not work, all not work. only i can import it
that's strange, if you can import without issues, then it should ideally work
cv2.error: OpenCV(4.8.0) D:\a\opencv-python\opencv-python\opencv\modules\core\include\opencv2/core/private.cuda.hpp:106: error: (-216:No CUDA support) The library is compiled without CUDA support in function 'throw_no_cuda'
im getting this error after following your video, do you know of a fix?
you might need to install cuda drivers for the nvidia gpu... If that's working then this issue will be resolved
@@HackersRealm I have the latest drivers and both cuda and cudnn are working when I use tensorflow and pytorch.
Only when I try to use GPU with opencv I get the problems
check your system variable paths if you have still that error because i fix that way
@@ofeksasson
same problem have you managed to solve it?
How to fix this error please:CMake Error at modules/dnn/CMakeLists.txt:41 (message):
DNN: CUDA backend requires cuDNN. Please resolve dependency or disable
OPENCV_DNN_CUDA=OFF
You need a nvidia graphics card and install the cuda toolkit to avoid this error
How do you enable nvidia video codec headers?
it is saying project files matbe invalid in cmake
same did u figure it out ive tried everything still no luck
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
i got error in configuration process, project files may be invalid
could you please share when you're getting this error? at which step?
@@HackersRealm its when am configure after all option check
same thing, have you been able to solve this problem?
@@ggbpb3249 nope sorry try windows 10
FOR ANYONE TRYING TO REPLICATE THE TEST SCRIPT:
CODE IS BELOW
import numpy as np
import cv2 as cv
import time
npTmp = np.random.random((1024, 1024)).astype(np.float32)
npMat1 = np.stack([npTmp, npTmp], axis=2)
npMat2 = npMat1
cuMat1 = cv.cuda_GpuMat()
cuMat2 = cv.cuda_GpuMat()
cuMat1.upload(npMat1)
cuMat2.upload(npMat2)
start_time = time.time()
cv.cuda.gemm(cuMat1, cuMat2, 1, None, 0, None, 1)
print("CUDA using GPU --- %s seconds ---" % (time.time() - start_time))
start_time = time.time()
cv.gemm(npMat1, npMat2, 1, None, 0, None, 1)
print("CPU --- %s seconds ---" % (time.time() - start_time))
is this video complete? where should we place the folder should we add any environment variable?
yes the video is complete, and once you complete all the steps, you can access the same way like importing opencv module
@@HackersRealm i tried and gave up , got a prebuilt whl package
@@angeljo6020If you can share the whl package link, it would be helpful to others as well.
@@angeljo6020 yoo could i get that prebuild whl package? sat here for 4 hours tryina figure this shit out
i get:
Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
Could NOT find BLAS (missing: BLAS_LIBRARIES)
Could NOT find LAPACK (missing: LAPACK_LIBRARIES)
Reason given by package: LAPACK could not be found because dependency BLAS could not be found.
Could NOT find Java (missing: Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE)
Could NOT find JNI (missing: JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 AWT JVM)
VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
Configuring incomplete, errors occurred!
And an error pop up, when trying to "Generate"
same
same
Это не работает. Сборка CMake прошла успешно. Но импорт cv2 невозможен
>>> import cv2
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'cv2'
kindly check the environment you're trying to use, I have used anaconda environment and installed there for usage.
@@HackersRealmя не могу найти в CMake параметр BUILD_opencv_python3
@@HackersRealm please explain how do i check the environment
@@YetiRUS type "conda env list" in cmd to check the environment. then install the packages on the selected environment. If you don't have anaconda, please install it, as it will ease the process
nice didnt work "Error in configuration process, project files may be invalid." i see you responding to all msgs just not these ones so no help at all
could you please share at which step you're getting this error?
@@HackersRealm in cmake following your guide ive even tried it in cmd
cmake -G "Visual Studio 17 2022" ^
-A x64 ^
-D CMAKE_BUILD_TYPE=Release ^
-D CMAKE_INSTALL_PREFIX=D:/OpenCV-GPU/opencv-4.10.0/build ^
-D OPENCV_EXTRA_MODULES_PATH=D:/OpenCV-GPU/opencv_contrib-4.x/modules ^
-D WITH_CUDA=ON ^
-D CUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2" ^
-D WITH_CUBLAS=ON ^
-D OPENCV_DNN_CUDA=ON ^
-D CMAKE_CXX_STANDARD=11 ^
-D CMAKE_CXX_STANDARD_REQUIRED=ON ^
-D WITH_CUDNN=ON ^
-D BUILD_opencv_world=ON ^
..
I still get an error
@@HackersRealm my comment got deleted or flagged un hide it
i was getting the same error, i changed visual studio s version from 2022 to 2017 and it is working now
@@abdulwahabmalik9452 dont you have to pay i cant go back to older vs? thanks anyway
Please make video introduction to nim game hackerrank solution