问题描述:
用pyinstaller打包包含onnxruntime-gpu库时,执行exe文件调用模型时,在终端会出现如下的报错提示:
[W:onnxruntime:Default, onnxruntime_pybind_state.cc:1827 onnxruntime::python::CreateInferencePybindStateModule] Init provider bridge failed.
版本
windows11
cuda11.8
onnxruntime-gpu1.15
可能原因
pyinstaller库未能将所有需要的动态链接库打包。
解决方案:
找到onnxruntime-gpu的安装位置,可以在终端用该命令查看
pip show onnxruntime-gpu
Name: onnxruntime-gpu
Version: 1.15.0
......
Location: d:\ai\anaconda\anaconda\envs\yolov8\lib\site-packages
打开该路径中的onnxruntime/capi文件夹,将如下两个文件onnxruntime_providers_cuda.dll
,onnxruntime_providers_shared.dll
复制
拷贝到你生成的可执行文件夹里的dist/main/_internal/onnxruntime/capi目录中
再次运行程序,完美解决
一些可能有用的链接
cuda和onnxruntime匹配版本