pytorch / pytorch/TensorRT

🐛 [Bug] Exporting `OptimizedModule` compiled model

Open
#2,742 6 comments 0 reactions 1 assignee View on GitHub

@peri044 is already working on this.

Since Apr 10, 2024.

bug Story: Runtime & Memory & Serialization
Dominant language
Python
Stars
3k
Forks
410
Avg merge
3d 18h
Merged PRs (30d)
78

Description

Bug Description

Hi All,
How are you?
I'm trying to save complied module but encountering errors. After I compiled my model I noticed that its type is OptimizedModule. Following this guide I was not sure how to save the model since there is no reference to OptimizedModule type. We tried to export the model using the following call trt_exp_program = torch_tensorrt.dynamo.export(trt_mod, [dummy_x.half(), dummy_embed.half()], "ep") but ended up with AttributeError: 'Model' object has no attribute 'graph'.
What is the correct way to save and load OptimizedModule?

Environment

We are using g4dn was machine with the following env:

  • Torch-TensorRT: 2.2.0
  • PyTorch Version: 2.2.0
  • CPU Architecture: x86_64
  • OS (e.g., Linux): Linux
  • How you installed PyTorch (conda, pip, libtorch, source): pip
  • Python version: 3.9.16
  • CUDA version: 11.8
  • GPU models and configuration: Tesla T4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.