Import not possible after build OpenCV with CUDA in Windows 10 (Python3.9)

Did you modify the code from @laurent.berger to point to your Nvidia SDK installation and your intsall location. e.g. for me the below works

os.add_dll_directory(‘D:/build/opencv/cuda_build/bin’)
os.add_dll_directory(‘C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.7/bin’)

If that doesn’t work then you can track down the dll using process monitor by filtering for

Process Name = python.exe
Operation = Create File

and looking for the dll which eventually fails. But if you are not familiar with the tool its better to verify the paths above first in case that works.

Alternatively if you are using CUDA 11.7 you could try installing this pre-built wheel after first making sure you have uninstalled all existing OpenCV wheels and deleted all files copied accross to Lib/site-packages (cv2 folder) when you built/installed OpenCv from source.

1 Like