1 TensorRT加载模型出现警告Using an engine plan file across different models of devices is not recommended and is likely to affect performance or even cause errors

经常会在使用TensorRT加载使用TensorRT转换后的深度学习模型时出现以下的警告:

[W] [TRT] Using an engine plan file across different models of devices is not recommended and is likely to affect performance or even cause errors.

在TensorRT的开发者文档中是这么描述的,

TensorRT –  Using an engine plan file across different models of devices is not recommended and is likely to affect performance or even cause errors-StubbornHuang Blog

开发者文档链接:https://docs.nvidia.com/deeplearning/tensorrt/developer-guide/index.html#faq

上面的原话是

This warning message can occur if you build an engine on a device with the same compute capability but is not identical to the device that is used to run the engine.
As indicated by the warning, it is highly recommended to use a device of the same model when generating the engine and deploying it to avoid compatibility issues.

翻译过来就是:

如果您在具有相同计算能力但与用于运行引擎的设备不同的设备上构建引擎,则会出现此警告消息。
如警告所示,强烈建议在生成和部署引擎时使用相同型号的设备以避免兼容性问题。

一般来说我们会使用TensorRT对onnx模型进行转换并保存到本地,方便我们在后续运行时加载模型更加快速,但是我们在后续使用TensorRT加载这个模型文件时,TensorRT内部会检查这个模型文件是不是在当前的这个GPU上创建的,有的时候TensorRT会检查到这个模型文件是在不同GPU上创建的,如果模型文件可以被正常加载并且可以推理,那么你可以忽略这个警告信息。

不过最好使用相同型号的GPU和同样的TensorRT版本去加载和推理所保存的模型文件,避免出现性能和其他未知问题。

参考链接