How to install OpenCV with CUDA GPU in windows 10 | Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ก.ย. 2024

ความคิดเห็น • 56

  • @Jem_Link
    @Jem_Link 2 หลายเดือนก่อน +1

    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!!

    • @HackersRealm
      @HackersRealm  2 หลายเดือนก่อน

      glad it helps!!!

  • @lukasTHEwise
    @lukasTHEwise ปีที่แล้ว +3

    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?

    • @LaloHao
      @LaloHao 6 หลายเดือนก่อน

      My CMake is also having problems finding python, did you manage to solve it?

  • @brooksnelson7870
    @brooksnelson7870 9 หลายเดือนก่อน +1

    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?

    • @HackersRealm
      @HackersRealm  9 หลายเดือนก่อน

      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

  • @kaviprasadjay2473
    @kaviprasadjay2473 7 หลายเดือนก่อน +4

    Error in configuration process, project files may be invalid.
    I'm getting this error after the process at 10 th minute

    • @BicTic
      @BicTic หลายเดือนก่อน

      same anyone got a fix?

    • @doyletheCat
      @doyletheCat 11 วันที่ผ่านมา

      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!

  • @장성규-u1d
    @장성규-u1d 5 หลายเดือนก่อน +1

    I built opencv using cmake. but i can not import cv2 in anaconda prompt.

  • @golden5023
    @golden5023 7 หลายเดือนก่อน +2

    If anyone else is having issues make sure you are using visual studio 2019 for some reason the 2022 version doesnt work :0

    • @akosbalint3485
      @akosbalint3485 3 หลายเดือนก่อน

      I have just run into this issue, vs2019 is working fine.

  • @MozillaMayhem
    @MozillaMayhem 8 หลายเดือนก่อน +1

    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?

    • @HackersRealm
      @HackersRealm  8 หลายเดือนก่อน

      You have to install cuda drivers for your nvidia gpu

    • @3dmixer552
      @3dmixer552 29 วันที่ผ่านมา

      @@HackersRealm I have but still getting this error:(

    • @doyletheCat
      @doyletheCat 11 วันที่ผ่านมา

      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!

  • @aimusicgenerates
    @aimusicgenerates 10 หลายเดือนก่อน

    i can import cv2 but not have any module: __version__ not work, all not work. only i can import it

    • @HackersRealm
      @HackersRealm  10 หลายเดือนก่อน

      that's strange, if you can import without issues, then it should ideally work

  • @ofeksasson
    @ofeksasson ปีที่แล้ว +1

    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
      @HackersRealm  ปีที่แล้ว

      you might need to install cuda drivers for the nvidia gpu... If that's working then this issue will be resolved

    • @ofeksasson
      @ofeksasson ปีที่แล้ว

      @@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

    • @emre_tif
      @emre_tif 9 หลายเดือนก่อน

      check your system variable paths if you have still that error because i fix that way
      @@ofeksasson

    • @TheAhmedps
      @TheAhmedps 6 หลายเดือนก่อน

      same problem have you managed to solve it?

  • @BLOCKBUSTERMOVIES1-br9ys
    @BLOCKBUSTERMOVIES1-br9ys 3 หลายเดือนก่อน

    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

    • @HackersRealm
      @HackersRealm  3 หลายเดือนก่อน

      You need a nvidia graphics card and install the cuda toolkit to avoid this error

  • @LaloHao
    @LaloHao 6 หลายเดือนก่อน

    How do you enable nvidia video codec headers?

  • @sam_razum
    @sam_razum 7 หลายเดือนก่อน +1

    it is saying project files matbe invalid in cmake

    • @Th3Test5656
      @Th3Test5656 5 หลายเดือนก่อน

      same did u figure it out ive tried everything still no luck

  • @LoukboomYT
    @LoukboomYT 23 วันที่ผ่านมา

    conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0

  • @ruzgar9629
    @ruzgar9629 หลายเดือนก่อน

    i got error in configuration process, project files may be invalid

    • @HackersRealm
      @HackersRealm  หลายเดือนก่อน

      could you please share when you're getting this error? at which step?

    • @LoukboomYT
      @LoukboomYT 23 วันที่ผ่านมา +1

      @@HackersRealm its when am configure after all option check

    • @ggbpb3249
      @ggbpb3249 12 วันที่ผ่านมา

      same thing, have you been able to solve this problem?

    • @LoukboomYT
      @LoukboomYT 12 วันที่ผ่านมา

      @@ggbpb3249 nope sorry try windows 10

  • @XDG-INACTIVE
    @XDG-INACTIVE 2 วันที่ผ่านมา

    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))

  • @angeljo6020
    @angeljo6020 7 หลายเดือนก่อน

    is this video complete? where should we place the folder should we add any environment variable?

    • @HackersRealm
      @HackersRealm  7 หลายเดือนก่อน

      yes the video is complete, and once you complete all the steps, you can access the same way like importing opencv module

    • @angeljo6020
      @angeljo6020 7 หลายเดือนก่อน

      @@HackersRealm i tried and gave up , got a prebuilt whl package

    • @HackersRealm
      @HackersRealm  7 หลายเดือนก่อน

      @@angeljo6020If you can share the whl package link, it would be helpful to others as well.

    • @MintHimself
      @MintHimself 3 หลายเดือนก่อน

      @@angeljo6020 yoo could i get that prebuild whl package? sat here for 4 hours tryina figure this shit out

  • @vebjrnpedersen1091
    @vebjrnpedersen1091 7 หลายเดือนก่อน

    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"

  • @YetiRUS
    @YetiRUS 3 หลายเดือนก่อน

    Это не работает. Сборка CMake прошла успешно. Но импорт cv2 невозможен
    >>> import cv2
    Traceback (most recent call last):
    File "", line 1, in
    ModuleNotFoundError: No module named 'cv2'

    • @HackersRealm
      @HackersRealm  3 หลายเดือนก่อน

      kindly check the environment you're trying to use, I have used anaconda environment and installed there for usage.

    • @YetiRUS
      @YetiRUS 3 หลายเดือนก่อน

      @@HackersRealmя не могу найти в CMake параметр BUILD_opencv_python3

    • @NicelySatisfied
      @NicelySatisfied หลายเดือนก่อน

      @@HackersRealm please explain how do i check the environment

    • @HackersRealm
      @HackersRealm  หลายเดือนก่อน

      @@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

  • @BicTic
    @BicTic หลายเดือนก่อน

    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

    • @HackersRealm
      @HackersRealm  หลายเดือนก่อน

      could you please share at which step you're getting this error?

    • @BicTic
      @BicTic หลายเดือนก่อน

      @@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

    • @BicTic
      @BicTic หลายเดือนก่อน

      @@HackersRealm my comment got deleted or flagged un hide it

    • @abdulwahabmalik9452
      @abdulwahabmalik9452 26 วันที่ผ่านมา

      i was getting the same error, i changed visual studio s version from 2022 to 2017 and it is working now

    • @BicTic
      @BicTic 26 วันที่ผ่านมา

      @@abdulwahabmalik9452 dont you have to pay i cant go back to older vs? thanks anyway

  • @rajajairamrameshbabu7605
    @rajajairamrameshbabu7605 ปีที่แล้ว

    Please make video introduction to nim game hackerrank solution