本文使用源码编译ort框架原因是需要打开某些开关(比如one-api),0.4.0版本有–openmp,–use_mkl,–use_mkldnn,–use_openvino等等开关,现在编译1.9.1版本的ort,openmp作者不建议打卡,当然可以自己调用线程数来加速,重要的是use_dnnl(mkldnn,mkl)这个开关,现在已经讲mkl,mkldnn合并。下面有一些注意事项,一切还是以官方文档为准。
在这里插入图片描述

官方编译文档

https://onnxruntime.ai/docs/build/inferencing.html#cpu

1.Install cmake-3.18 or higher.
2.GCC 4.x and below are not supported.
编译时候可以使用–parallel加速编译,使用–build_wheel生成wheel,直接pip进行安装。

————————————————————————————————————————————

1.升级gcc
centos7自带的gcc非常老,我的是4.8,这里不能直接升级,使用Developer Toolset 7
升级更简单。

https://www.jianshu.com/p/76fb9b6a781b

scl enable devtoolset-7 bash,里写的是bash,可以用zsh
出现了 Could not create lock at /var/run/yum.pid:被锁的问题,首先rm -rf /var/run/yum.pid,如果不起作用可能是yum被占用 ps -aux | grep yum,杀掉pid。

2.编译之前先看echo $path有没有cmake和gcc
没有的话,加载一下环境变量

export PATH=/opt/tools/cmake-3.20.2-linux-x86_64/bin:$PATH

如果报错subprocess.CalledProcessError: Command '['/opt/venvs/onnxruntime/bin/python3', '/b_qiu/onnxruntime/setup.py', 'bdist_wheel', '--use_dnnl']' returned non-zero exit status 1.
先看gcc和cmake版本,环境变量加了没,numpy 和wheel有没有,rm -rf build,在重新编译。

3.编译ort

./build.sh --parallel --config Release --use_dnnl --build_wheel

就完成编译了。
在这里插入图片描述

GitHub 加速计划 / on / onnxruntime
25
3
下载
microsoft/onnxruntime: 是一个用于运行各种机器学习模型的开源库。适合对机器学习和深度学习有兴趣的人,特别是在开发和部署机器学习模型时需要处理各种不同框架和算子的人。特点是支持多种机器学习框架和算子,包括 TensorFlow、PyTorch、Caffe 等,具有高性能和广泛的兼容性。
最近提交(Master分支:7 个月前 )
c5d1416e 7 小时前
aa87e34e ### Description WebGPU, VitisAI, and DML are missing from the list. ### Motivation and Context If users misspell a provider name this error should be showing them the full possibilities. Leaving one out will lead to confusion. I noticed it when testing new providers in GenAI that the error message was not up to date. 8 小时前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐