Improve ML cupy memory estimation#644
Merged
Merged
Conversation
Contributor
Author
|
Keep fractional idea but never go below an absolute value (increase that from 200 MB to 400 MB) |
9a49b9f to
6f202eb
Compare
d3fcc8c to
6fb03cd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In some cases, we have noticed that when the last block of data is allocated in the ML cupy engine, there is not enough memory available despite upfront calculations on how much device memory is free.
The origin of this issue could be related to discrepancies between memory allocation of cupy and via the lower level CUDA runtime API - this needs further investigation.
As an intermediate solution, I am adding the capabilities to leave more extra device memory (now defined as a fraction of total memory) and allow users to change this "safety margin" by adding an environment variable PTYPY_DEVICE_MEM_SAFETY.
The new default for this safety margin is 2.5% of the total device memory or at least 400 MB (previously it was hardcoded to 200 MB) to make sure we can always operate on low-memory devices.