Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to save a model to TRT file? Not covered in the docs #928

Open
talcs opened this issue May 29, 2024 · 1 comment
Open

How to save a model to TRT file? Not covered in the docs #928

talcs opened this issue May 29, 2024 · 1 comment

Comments

@talcs
Copy link

talcs commented May 29, 2024

I'd like to save my model into TRT file. Could you please provide a sample code?

@jaybdub
Copy link
Contributor

jaybdub commented May 30, 2024

Hi @talcs,

Thanks for reaching out.

Assuming you built your model like

model_trt = torch2trt(...)

You can then save the raw TensorRT engine like this.

with open("model.plan", 'wb') as f:
    f.write(model_trt.engine.serialize())

The input and output names will be

print(model_trt.input_names)
print(model_trt.output_names)

Let me know if this helps or you run into any issues.

Best,
John

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants