【模型部署】在C++和Python中配置ONNXRuntime环境

1. C++端配置

官网下载链接:https://onnxruntime.ai/

github下载地址:https://github.com/microsoft/onnxruntime/releases

1.1 GPU版本

在GPU端使用OnnxRuntime进行推理时,需要提前安装对应版本的CUDA和cuDNN。

登录ONNXRuntime官网,按如下步骤下载ONNXRuntime_GPU版本源文件microsoft.ml.onnxruntime.gpu.1.12.1.nupkg,然后使用7zip工具进行解压

 

也可以在github上边直接下载编译好的包

 在VS中配置过程如下

在【属性管理器】-【通用属性】-【VC++目录】-【包含目录】添加路径

  D:\DeepLearningTools\microsoft.ml.onnxruntime.1.12.1\build\native\include

在【属性管理器】-【通用属性】-【VC++目录】-【库目录】添加路径

  D:\DeepLearningTools\microsoft.ml.onnxruntime.1.12.1\runtimes\win-x64\native

在【属性管理器】-【链接器】-【输入】-【附加依赖项】添加文件

  onnxruntime.lib

最后,将onnxruntime.dll文件放在程序运行目录Release下边,或者将该文件根目录添加至Path环境变量

1.2 CPU版本

CPU版本的安装配置同上 

2. Python端配置

onnx

pip install onnx==1.12.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

onnxruntime

pip install onnxruntime==1.12.1 -i https://pypi.tuna.tsinghua.edu.cn/simple 

onnxruntime-gpu

pip install onnxruntime-gpu==1.12.1 -i https://pypi.tuna.tsinghua.edu.cn/simple

  

posted @ 2023-03-19 20:38  最菜程序员Sxx  阅读(1951)  评论(0编辑  收藏  举报