Skip to content

should add cuda dll path via os.add_dll_directory on windows #16500

@cyyever

Description

@cyyever
System information (version)
  • OpenCV => master
  • Operating System / Platform =>win10
  • Compiler => vs2019
  • CUDA 10.2
  • Python 3.8
Detailed description

I compiled opencv from source with cuda and python supports and encountered "import cv2 ,dll failed to load " error, after spent a lot of time solving this problem, I found that dll loading policy has changed in python3.8 such that PATH and the current working directory are no longer used.
Please see this note

Steps to reproduce
  1. Compiler opencv under python3.8 on windows.
  2. Can't load cv2 even when C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin is in PATH
  3. Copy all cuda DLL to C:\Python38 then it works, which shows that python3.8 doesn't use PATH when loading DLLs.
  4. Now remove all cuda DLLs from C:\Python38 and add C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin via os.add_dll_directory in cv2/init.py ,then it will work too.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions