介绍¶
该工具链通过一个代理(shim)在运行时捕获 TensorRT 网络创建和构建参数,然后确定性地重放它们以重现引擎构建。使用它来调试或重现独立于原始框架的构建。
先决条件¶
已安装 TensorRT (确保您知道其
lib
和bin
目录的绝对路径)您的 TensorRT
lib
目录中提供了libtensorrt_shim.so
您的 TensorRT
bin
目录中提供了tensorrt_player
快速开始:捕获¶
TORCHTRT_ENABLE_TENSORRT_API_CAPTURE=1 python test.py
您应该在 /tmp/torch_tensorrt_{current_user}/shim
中看到生成的 shim.json
和 shim.bin
。
重放:从捕获中构建引擎¶
使用 tensorrt_player
在没有原始框架的情况下重放捕获的构建
tensorrt_player -j /absolute/path/to/shim.json -o /absolute/path/to/output_engine
这将在 output_engine
处生成一个序列化的 TensorRT 引擎。
验证引擎¶
使用 trtexec
运行引擎
trtexec --loadEngine=/absolute/path/to/output_engine
注意事项¶
确保 shim 使用的
libnvinfer.so
与您环境中的 TensorRT 版本匹配。如果安装了多个 TensorRT 版本,请优先使用如上所示的绝对路径。
目前不支持捕获多个引擎,在图中断的情况下,将只捕获第一个引擎。