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

What exactly does "Optimal" mean? #45

Closed
carnivar10 opened this issue Oct 18, 2023 · 6 comments
Closed

What exactly does "Optimal" mean? #45

carnivar10 opened this issue Oct 18, 2023 · 6 comments
Labels
good first issue Good for newcomers question Further information is requested

Comments

@carnivar10
Copy link

carnivar10 commented Oct 18, 2023

ask2

when l export a TensorRT-based Engine, I know exactly what Min/Max Width and Height are for, but I don't know what Optimal is, and I didn't find anything about it in the description on the right. Does anyone know anything about it?

@contentis
Copy link
Collaborator

Optimal is the config TensorRT will optimize for, whereas min and max only define the range in which it needs to be operable.
E.g. an engine compiled with optimal width/height set to 512, will perform best when running it at 512x512.

@contentis contentis added good first issue Good for newcomers question Further information is requested labels Oct 18, 2023
@carnivar10
Copy link
Author

Optimal is the config TensorRT will optimize for, whereas min and max only define the range in which it needs to be operable. E.g. an engine compiled with optimal width/height set to 512, will perform best when running it at 512x512.

Thanks for the answer!! So if I start my image at 512 and grow it to 2048, do I need 3 engines with Optimal set to 512, 1024, and 2048? how would you recommend setting Optimal?

@contentis
Copy link
Collaborator

Technically, you could do an engine with min=512, opt=1024, max=2048 that covers all cases. But performance will probably be suboptimal at 512 and 2048. How large the performance impact is going to be is hard to estimate. In that case, I'd recommend exporting multiple engines, using your most commonly used resolutions for optimal.

@carnivar10
Copy link
Author

base512 base1024 base2048

I tried changing the Optimal Width and Height to 512, 1024, and 2048, but it doesn't seem to make much of a difference (I did this by pressing Force Rebuild on TensorRT Export and then creating a new Engine)

@contentis
Copy link
Collaborator

TensorRT sometimes is more art than science. It could be that 2048 is so large that, at that point, it doesn't make a difference. For 1024 you can definitely see a performance delta between the opt=512 and opt=1024 engine.

From your experience is 1.0x it/s slow?

@carnivar10
Copy link
Author

The difference in speed between using TensorRT and not using TensorRT is clear, but it doesn't seem to be an optimal value (at low resolutions, the images are generated very quickly, so it may be that can't tell)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants