-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
add available memory check to accelerators #4508
Merged
Merged
Conversation
This file contains 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
mrwyattii
reviewed
Oct 12, 2023
Co-authored-by: Michael Wyatt <[email protected]>
@delock, FYI |
tjruwase
approved these changes
Oct 12, 2023
mrwyattii
approved these changes
Oct 13, 2023
Thanks for reminding. I think the CPU part is good. We will add to XPU backend as well. |
baodii
pushed a commit
to baodii/DeepSpeed
that referenced
this pull request
Nov 7, 2023
* add available memory check to accelerator * catch case where nvmlInit fails * add pynvml to reqs * fix for cpu systems * Update accelerator/cuda_accelerator.py Co-authored-by: Michael Wyatt <[email protected]> * simplify --------- Co-authored-by: Michael Wyatt <[email protected]>
mauryaavinash95
pushed a commit
to mauryaavinash95/DeepSpeed
that referenced
this pull request
Feb 17, 2024
* add available memory check to accelerator * catch case where nvmlInit fails * add pynvml to reqs * fix for cpu systems * Update accelerator/cuda_accelerator.py Co-authored-by: Michael Wyatt <[email protected]> * simplify --------- Co-authored-by: Michael Wyatt <[email protected]>
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.
There are many scenarios where we need to get an accurate estimate of the available memory on a device. Currently we rely on the torch memory allocator stats to give us this information, however there are several cases where memory may be allocated outside the view of torch. This means that
torch.cuda.get_device_properties(device_index).total_memory - torch.cuda.memory_allocated(device_index)
is not accurate. This is usually less of a problem on data center GPUs but quite common on consumer grade GPUs that are often shared between torch and the operating system.This PR introduces
available_memory
to the abstract accelerator interface. On CUDA devices we can rely onpynvml
to get the ground truth w.r.t. available memory.This also introduces a hard dependency on
pynvml
. I have tested on non-GPU systems and this package seems to install successfully but fails at runtime at thenvmlInit()
call. We fall back to using torch stats for memory in cases where pynvml is not functional.