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 convert model.onnx and model.onnx_data to trt model #4235

Closed
Sdamuu opened this issue Nov 4, 2024 · 2 comments
Closed

How to convert model.onnx and model.onnx_data to trt model #4235

Sdamuu opened this issue Nov 4, 2024 · 2 comments

Comments

@Sdamuu
Copy link

Sdamuu commented Nov 4, 2024

I want to convert the onnx model to trt model, but the onnx model is larger than 2Gb, so it has two files, 'model.onnx' and 'model.onnx_data',how can I convert the model to trt by using trtexec ? or python scripts ?
onnx model like multilingual-e5-large

model like:
Image

thank a lot, looking forward to your reply!

@lix19937
Copy link

lix19937 commented Nov 5, 2024

You can see https://github.com/onnx/onnx/blob/main/docs/PythonAPIOverview.md#loading-an-onnx-model-with-external-data, or use polygraphy to load model.onnx_data fusion to model.onnx, then get a new onnx.

graph = gs.import_onnx(onnx.load("model.onnx"))

model = gs.export_onnx(graph)

from onnx.external_data_helper import convert_model_to_external_data

convert_model_to_external_data(model, location="model.onnx_data")

onnx.save(model, "model_fusion.onnx")

then use trtexec as normal.

@Sdamuu
Copy link
Author

Sdamuu commented Nov 5, 2024

You can see https://github.com/onnx/onnx/blob/main/docs/PythonAPIOverview.md#loading-an-onnx-model-with-external-data, or use polygraphy to load model.onnx_data fusion to model.onnx, then get a new onnx.

graph = gs.import_onnx(onnx.load("model.onnx"))

model = gs.export_onnx(graph)

from onnx.external_data_helper import convert_model_to_external_data

convert_model_to_external_data(model, location="model.onnx_data")

onnx.save(model, "model_fusion.onnx")
then use trtexec as normal.

thanks a lot, it works!

@Sdamuu Sdamuu closed this as completed Nov 5, 2024
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