-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
[train][docs] update docstrings/quickstarts to work when use_gpu=True
#31692
Conversation
Signed-off-by: Matthew Deng <[email protected]>
Signed-off-by: Matthew Deng <[email protected]>
use_gpu=True
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Orthogonal to this, but I think that if we detect we are in a train session, iter_torch_batches
should automatically use the default device unless specified otherwise.
@@ -12,6 +12,10 @@ | |||
from ray.train.huggingface import HuggingFaceTrainer | |||
from ray.air.config import ScalingConfig | |||
|
|||
|
|||
# If using GPUs, set this to True. | |||
use_gpu = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dumb, yet effective trick for cases you want to show users you can use gpus, but want cpus on CI:
use_gpu = True # include in docs
use_gpu = False # exclude
<code using use_gpu>
@Yard1 yeah I was thinking the same thing, cc @stephanie-wang this could be a nice extension to the |
I've got a PR here, comments appreciated - #31745 |
Ah sorry- let's get this in ASAP...let me know when it's ready to merge. I can update this documentation in that PR. |
@amogkam I think it's good to merge as is! |
Signed-off-by: Matthew Deng [email protected]
Fixes Trainer docstrings and quickstarts to work when
use_gpu=True
.Why are these changes needed?
iter_torch_batches
to move to the proper device.torch
andhorovod
which useiter_torch_batches
.tensorlfow
andhuggingface
which handle device transfer natively.use_gpu
to the top of each code snippet for easier control handling.Related issue number
Closes #31684
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.