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

[tune] fix gpu check #13825

Merged
merged 17 commits into from
Feb 4, 2021
Merged

[tune] fix gpu check #13825

merged 17 commits into from
Feb 4, 2021

Conversation

richardliaw
Copy link
Contributor

Why are these changes needed?

closes #13486

Related issue number

Checks

  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

amogkam and others added 8 commits January 29, 2021 17:23
Signed-off-by: Richard Liaw <rliaw@berkeley.edu>
Signed-off-by: Richard Liaw <rliaw@berkeley.edu>
Signed-off-by: Richard Liaw <rliaw@berkeley.edu>
@@ -471,18 +471,16 @@ def wait_for_gpu(gpu_id=None, gpu_memory_limit=0.1, retry=20):
gpu_id (Optional[str]): GPU id to check. Must be found
within GPUtil.getGPUs(). If none, resorts to
the first item returned from `ray.get_gpu_ids()`.
gpu_memory_limit (float): If memory usage is below
gpu_memory_limit (float): If fractional memory usage is below
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the original docstring was correct here. We're comparing absolute memory usage (memoryUsed) vs. the absolute amount we need to have available (gpu_memory_limit). The fact that the default value here is 0.1 might be confusing. Shouldn't we just require passing a GPU limit here? And maybe state that this is memory usage in bytes (if this is in bytes, which I think it is?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you keep it as a fraction and compare against memoryUtil instead of memoryUsed?

https://github.com/anderskm/gputil/blob/master/GPUtil/GPUtil.py#L50

This is more intuitive for us, particularly since in most cases you just want to say "wait until all the gpu memory is free" or wait_for_gpu(gpu, 1.0).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so now, the usage is:

wait_for_gpu(target_util=0.1) or wait_for_gpu(target_util=0) (for full blocking)

for i in range(int(retry)):
gpu_object = GPUtil.getGPUs()[gpu_id]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gpu_id is a string, but getGPUs() returns a list. You probably need to compare against the GPU id (which is also an int) returned in the list.

Signed-off-by: Richard Liaw <rliaw@berkeley.edu>
Signed-off-by: Richard Liaw <rliaw@berkeley.edu>
Signed-off-by: Richard Liaw <rliaw@berkeley.edu>
Signed-off-by: Richard Liaw <rliaw@berkeley.edu>
Signed-off-by: Richard Liaw <rliaw@berkeley.edu>
Signed-off-by: Richard Liaw <rliaw@berkeley.edu>
Signed-off-by: Richard Liaw <rliaw@berkeley.edu>
Copy link
Contributor

@krfricke krfricke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just one tiny nit

python/ray/tune/utils/util.py Show resolved Hide resolved
@richardliaw richardliaw merged commit 0fc81e2 into ray-project:master Feb 4, 2021
@richardliaw richardliaw deleted the gpu branch February 4, 2021 09:14
fishbone pushed a commit to fishbone/ray that referenced this pull request Feb 16, 2021
Co-authored-by: Amog Kamsetty <amogkamsetty@yahoo.com>
fishbone added a commit to fishbone/ray that referenced this pull request Feb 16, 2021
fishbone added a commit to fishbone/ray that referenced this pull request Feb 16, 2021
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

Successfully merging this pull request may close these issues.

[tune] wait_for_gpu
4 participants