10

opencv cuda加速编译后调用python接口后报错ImportError: DLL load failed while impo...

 3 years ago
source link: https://blog.csdn.net/wa_workforwa/article/details/112181984
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

opencv cuda加速编译后调用python接口后报错ImportError: DLL load failed while importing cv2记录

original.png
不想再配环境了 2021-01-04 16:07:55 articleReadEyes.png 561

opencv cuda加速编译后调用python接口后报错ImportError: DLL load failed while importing cv2记录

我的环境:

  • windows10
  • python3.8.5
  • cuda10.2
  • cudnn7.6.4
  • vs2017

结合以下两篇文章对CMAKE进行了配置(A篇中也分享了两篇博客):
A篇
B篇

用vs2017生成后,python的site-pakages里并没有生成cv2的目录,则使用A篇中的在opencv生成目录中的python_loader中使用命令行

python setup.py install
python
>>>import cv2
ImportError: DLL load failed while importing cv

使用dependency walker查看python的site-package下生成的cv2.cp38-win_amd64.pyd文件的依赖情况,显示很多系统预装的dll文件依赖缺失
在这里插入图片描述
随后尝试了多种方法依旧报错。无意中使用python setup.py install在conda创建的python环境中安装opencv,在pip list中显示安装opencv,而不是opencv-python。这时用import cv2测试不再报错,并且用opencv自带的dnn调用yolov3进行目标检测时,速度明显较只安装opencv-python包有所提升,cuda的利用率也从0变到30%,说明支持cuda加速。在这里插入图片描述
对比一下自己安装的python与conda下创建的python环境:
在这里插入图片描述
在这里插入图片描述


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK