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

multiple IExecutionContext for getDeviceMemorySize #3437

Closed
tp-nan opened this issue Nov 8, 2023 · 10 comments
Closed

multiple IExecutionContext for getDeviceMemorySize #3437

tp-nan opened this issue Nov 8, 2023 · 10 comments
Assignees
Labels
triaged Issue has been triaged by maintainers

Comments

@tp-nan
Copy link

tp-nan commented Nov 8, 2023

I have multiple IExecutionContexts, each with an different OptimizationProfile.

virtual size_t nvinfer1::ICudaEngine::getDeviceMemorySize() const

      Return the amount of device memory required by an execution context.

Is ICudaEngine's getDeviceMemorySize unrelated to OptimizationProfile?

@zerollzeng
Copy link
Collaborator

I think the OptimizationProfile was determined when you build the engine, so each each engine has its own OptizationProfile.

I have multiple IExecutionContexts, each with an different OptimizationProfile.

In this case I think What you mean is multiple ICudaEngine with different IOptimizationProfile?

Is ICudaEngine's getDeviceMemorySize unrelated to OptimizationProfile?

I think the answer it's no, IOptimizationProfile can affect the size returned by getDeviceMemorySize.

These are just my understanding, @ttyio @pranavm-nvidia please correct if I made any mistake :-)

@zerollzeng zerollzeng self-assigned this Nov 12, 2023
@zerollzeng zerollzeng added the triaged Issue has been triaged by maintainers label Nov 12, 2023
@tp-nan
Copy link
Author

tp-nan commented Nov 13, 2023

Hi, thanks for your reply.

I build one ICudaEngine with multiple IOptimizationProfiles and multiple IExecutionContexts, and get Device Memory by ICudaEngine.getDeviceMemorySize, then I call IExecutionContext's setDeviceMemory. So I'm wondering this device memory size is sum of all IExecutionContexts(IOptimizationProfiles), or is only for one IExecutionContext? If the answer is the former, when I call setDeviceMemory for each IExecutionContext, is there any wasted memory? If the answer is the later, does IExecutionContext with different IOptimizationProfile range need the same device memory size?

@zerollzeng
Copy link
Collaborator

or is only for one IExecutionContext?

I think it's this.

does IExecutionContext with different IOptimizationProfile range need the same device memory size?

I think the memory size should be different(but not always, it depends on kernel tactics), you can verified this by experiment.

@tp-nan
Copy link
Author

tp-nan commented Nov 14, 2023

or is only for one IExecutionContext?

I think it's this.

does IExecutionContext with different IOptimizationProfile range need the same device memory size?

I think the memory size should be different(but not always, it depends on kernel tactics), you can verified this by experiment.

Thx for your reply. If so, I would suggest getDeviceMemorySize should be a method of IExecutionContext/IOptimizationProfile, not ICudaEngine. It is quite strange and I donot quite understand...

@zerollzeng
Copy link
Collaborator

@oxana-nvidia @nvpohanh any comments here ^ ^

@oxana-nvidia
Copy link
Collaborator

We are currently discussing possible API changes in this area for the next major release.

@nvpohanh
Copy link
Collaborator

I think the answer it's no, IOptimizationProfile can affect the size returned by getDeviceMemorySize.

@zerollzeng I don't think this is correct. I think engine->getDeviceMemorySize() returns the maximum of the device mem sizes from all optimization profiles. So the value is a fixed value, regardless of which profile(s) the contexts are set to.

@zerollzeng
Copy link
Collaborator

Oh my understanding is wrong. sorry.

@nvpohanh
Copy link
Collaborator

No worries! As Oxana said, we are discussing some improvements on these APIs in next TRT version. Hopefully things will be improved in the future

@ttyio
Copy link
Collaborator

ttyio commented Apr 16, 2024

closing since no activity for more than 3 weeks, thanks all

@ttyio ttyio closed this as completed Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaged Issue has been triaged by maintainers
Projects
None yet
Development

No branches or pull requests

5 participants