前言
windows10下编译onnxruntime在网上的教程可谓是风毛菱角,经过本人几天的努力钻研,花了九牛二虎之力,终于是完成了这个操作。
环境
cuda版本:11.4
cudnn版本: 8.2.2.26
onnxruntime:1.10.0
Visual Studio 2019
cuda、cudnn和onnxruntime对应的版本可以参考官网:https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html
**注意:**cuda、cudnn和onnxruntime的版本一定要对应,否则编译会出错。
下载源码
onnxruntime源码地址:https://github/microsoft/onnxruntime
1、下载:
git clone -b rel-1.10.0 --recursive https://github/Microsoft/onnxruntime
如果下载慢,也可以用gittee上的镜像:https://gitee/mirrors_microsoft/onnxruntime
2、更新包
cd onnxruntime
git submodule update --init --recursive
3、编译脚本
.\build.bat --build_shared_lib --parallel --use_cuda --cuda_version 11.4 --cuda_home "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4" --cudnn_home "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4" --cmake_generator "Visual Studio 16 2019" --skip_tests --config Release
需要添加参数可以参考onnxruntime官方文档
编译成功如下图所示:
遇到问题
参照网上的编译流程,期间遇到过cuda版本不对应的问题
还有编译时的一个参数–cuda_version 11.4时必须设置正确的,因为没有设置正常编译都进行不下去。
更多推荐
windows10 编译onnxruntime
发布评论