Hi, I want to use the tensorRT library in Python to measure the inference time of a PyTorch model. I start by converting the Pytorch model to Onnx, then I build the tensorRT engine using trtexec and finally I measure the network’s inference latency using a custom function made using tensorRT Python API. When tensorRT is imported before torch in the script, everything works fine. However, when torch is imported before tensorRT, the conversion of the PyTorch model to Onnx using torch’s onnx.export() function crashes with a Windows access violation. How can I solve this issue?
Environment
TensorRT Version:
GPU Type: GeForceRTX 3080 Ti Laptop GPU
Nvidia Driver Version: 522.06
CUDA Version: 11.8
CUDNN Version: 8.6
Operating System + Version: Windows 11
Python Version (if applicable): 3.10.10
PyTorch Version (if applicable): 2.0
Relevant Files
reproduce.py (739 Bytes)
I attached a Python script reproducing the issue.
Steps To Reproduce
- Run the script.
- When tensorRT is imported before torch, “done” prints and onnx file is generated.
- When torch is imported before tensorRT, a Windows access violation happens.
Error message:
Windows fatal exception: access violation
Current thread 0x0000305c (most recent call first):
File “C:\Users\xxxx\anaconda3\envs\test\lib\site-packages\torch\onnx\utils.py”, line 993 in _create_jit_graph
File “C:\Users\xxxx\anaconda3\envs\test\lib\site-packages\torch\onnx\utils.py”, line 1113 in _model_to_graph
File “C:\Users\xxxx\anaconda3\envs\test\lib\site-packages\torch\onnx\utils.py”, line 1548 in _export
File “C:\Users\xxxx\anaconda3\envs\test\lib\site-packages\torch\onnx\utils.py”, line 506 in export
File “C:\Users\xxxx\Documents\pyTorchAndtensorRT\reproduce.py”, line 24 in