TensorRT – 基于TensorRT的多线程并发推理方案
本文作者:StubbornHuang
版权声明:本文为站长原创文章,如果转载请注明原文链接!
原文标题:TensorRT – 基于TensorRT的多线程并发推理方案
原文链接:https://www.stubbornhuang.com/2536/
发布于:2023年03月06日 17:48:01
修改于:2023年03月15日 8:52:09

1 TensorRT的多线程并发推理方案
TensorRT在对模型推理速度已经有了非常大的提升了,那如果能够基于TensorRT做并行推理,既可以有效降低推理延迟,也能增加服务吞吐量,那岂不是酷毙了?
那么能用TensorRT做多线程并发吗?
我们看看TensorRT的官方开发者文档怎么说:
In general, TensorRT objects are not thread safe; accesses to an object from different threads must be serialized by the client.
The expected runtime concurrency model is that different threads will operate on different execution contexts. The context contains the state of the network (activation values, and so on) during execution, so using a context concurrently in different threads results in undefined behavior.
To support this model, the following operations are thread safe:
- Nonmodifying operations on a runtime or engine.
- Deserializing an engine from a TensorRT runtime.
- Creating an execution context from an engine.
- Registering and deregistering plug-ins.
There are no thread-safety issues with using multiple builders in different threads; however, the builder uses timing to determine the fastest kernel for the parameters provided, and using multiple builders with the same GPU will perturb the timing and TensorRT’s ability to construct optimal engines. There are no such issues using multiple threads to build with different GPUs.
上面的第一句话清楚的提到,TensorRT不是线程安全的,需要我们自己管理不同线程之间的对象访问。
(1)请购买正版资源,支持原作者和出版社;
(2)资源收集自互联网,仅供自我学习,请在下载后24小时内删除该资源,如下载者将此资源用于其他非法用途,本站不承担任何法律责任;如有侵权,请立即联系我,马上删除!
(3)此捐赠下载方式无需注册+登录账号,当然如果您喜欢本站也可注册账号;
(4)所支付的款项为捐赠本站款项,而并非付费下载所付款项,本站会在您捐赠本站后显示隐藏内容,请知悉,先非常感谢您对本站的捐赠;
(5)本站支付使用Payjs,该第三方支付方式为微信官方授权的服务商,无支付风险,详情请查看:https://payjs.cn;
(6)请尽量不要使用手机浏览器以及电脑浏览器的无痕模式进行支付操作,以免造成支付成功但未显示隐藏内容。
(7)点击立即购买按钮后弹出选择支付方式页面,选择任意支付方式点击后会跳转到新的二维码支付页面,支付成功后会弹出支付成功的提示框,点击提示框会自动刷新页面显示隐藏内容;另外请不要重复支付,避免财产损失;
(8)在2021年7月27日前,本站采用注册+登录+评论的免费下载模式,旨在节省大家寻找宝贵资源的时间,为大家带来珍贵的知识来源,但是从2021年7月27日起,因遭受注册轰炸和恶意爬虫造成网站负载过大导致宕机,被迫无奈,为减少网站运营时间成本,对部分资源进行捐赠下载,添加支付是反爬虫的最好方式,在此对未享受到免费下载福利的访客表示歉意;
(9)如遇支付页面未弹出、支付成功但未显示隐藏内容、资源链接失效或者提取码出错等情况请发送邮件到stubbornhuang@qq.com或者直接联系QQ:623256052,会尽快为您解决!加我时请备注原因,谢谢!或者点击按钮点击反馈进入反馈页面进行问题反馈
(10)由以上捐赠下载带来的不便请您谅解,如出现重复付费的情况,请联系我,我会尽快返回您的退款!
当前分类随机文章推荐
- TensorRT - Using an engine plan file across different models of devices is not recommended and is likely to affect performance or even cause errors 阅读73次,点赞0次
- TensorRT - Windows下TensorRT下载与配置 阅读1578次,点赞0次
- TensorRT - workspace的作用 阅读331次,点赞0次
- TensorRT - 转换onnx模型出现Slice_74 requires bool or uint8 I/O but node can not be handled by Myelin错误 阅读294次,点赞0次
- TensorRT - 基于TensorRT的多线程并发推理方案 阅读172次,点赞2次
- TensorRT - onnx_graphsurgeon工具库的安装与API简介 阅读531次,点赞0次
- TensorRT - 安装TensorRT工具Polygraphy 阅读3780次,点赞0次
- TensorRT - 解决INVALID_ARGUMENT: getPluginCreator could not find plugin ScatterND version 1,TensorRT找不到ScatterND插件的问题 阅读3286次,点赞0次
- TensorRT - 使用torch普通算子组合替代torch.einsum爱因斯坦求和约定算子的一般性方法 阅读2643次,点赞1次
- TensorRT - 使用Polygraphy工具比较onnx模型和TensorRT模型的推理结果是否一致 阅读314次,点赞1次
全站随机文章推荐
- Duilib - 在主界面xml描述文件中使用ChildLayout或者Include嵌入子界面xml描述文件 阅读471次,点赞0次
- 资源分享 - Digital Modeling of Material Appearance 英文高清PDF下载 阅读1442次,点赞0次
- 资源分享 - Vulkan Programming Guide - The Official Guide to Learning Vulkan 英文高清PDF下载 阅读2579次,点赞0次
- 简单粗暴:使用pycharm安装对应的Python版本第三方包 阅读3541次,点赞0次
- TensorRT - 使用Polygraphy工具比较onnx模型和TensorRT模型的推理结果是否一致 阅读314次,点赞1次
- 资源分享 - 机器学习 (西瓜书) 周志华著PDF下载 阅读30262次,点赞30次
- C++ - 使用正则判断字符串是否全是中文 阅读1051次,点赞0次
- 资源分享 - An Introduction to Computational Fluid Dynamics - The Finite Volume Method (Second Edition)英文高清PDF下载 阅读178次,点赞0次
- Python - 使用Python+websockets时报错:AttributeError: module 'websockets' has no attribute 'serve' 阅读1500次,点赞0次
- 资源分享 - Color Imaging - Fundamentals and Applications 英文高清PDF下载 阅读1192次,点赞0次
评论
167