本文最后更新于:2025年1月2日 下午
在 onnxruntime python 库中可以加载在内存或者显存中,分别使用 cpu 和 gpu 进行推断运算,本文记录 onnxruntime 将模型加载到指定 gpu 的步骤。
安装
这里我们使用 1.18.0 的 onnx 库
1 |
|
指定 gpu 配置
将需要加载模型的 gpu id 填入 device_id,需要用字符串类型
1 |
|
也有一种实现思路是在 Docker 内仅映射部分 gpu
1 |
|
参考资料
- https://blog.csdn.net/weixin_41449637/article/details/116486847
- https://github.com/cap-ntu/ML-Model-CI/issues/37
文章链接:
https://www.zywvvd.com/notes/study/deep-learning/deploy/onnx-percific-gpu/onnx-percific-gpu/
“觉得不错的话,给点打赏吧 ୧(๑•̀⌄•́๑)૭”

微信支付

支付宝支付
Python onnxruntime-gpu 指定 gpu 加载模型
https://www.zywvvd.com/notes/study/deep-learning/deploy/onnx-percific-gpu/onnx-percific-gpu/