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

Issue on page /tune/tutorials/tune-resources.html #28206

Closed
davidegraff opened this issue Aug 31, 2022 · 1 comment · Fixed by #28210
Closed

Issue on page /tune/tutorials/tune-resources.html #28206

davidegraff opened this issue Aug 31, 2022 · 1 comment · Fixed by #28210
Assignees
Labels
good first issue Great starter issue for someone just starting to contribute to Ray P2 Important issue, but not time-critical tune Tune-related issues

Comments

@davidegraff
Copy link

The problem
The code snippets on this page are generally of the form:

# If you have 8 GPUs, this will run 8 trials at once.
tuner = tune.Tuner(tune.with_resources(trainable, {"gpu": 1}, tune_config=tune.TuneConfig(num_samples=10))
results = tuner.fit()

This code a missing a closing parenthesis and will result in a SyntaxError if a user tries to run it. Moreover, it causes confusion with respect to where a TuneConfig should be placed: inside tune.with_resources or tune.Tuner.__init__?

Suggested Fixes

  1. add the closing parenthesis:
# If you have 8 GPUs, this will run 8 trials at once.
tuner = tune.Tuner(tune.with_resources(trainable, {"gpu": 1}), tune_config=tune.TuneConfig(num_samples=10))
results = tuner.fit()

# If you have 4 CPUs on your machine and 1 GPU, this will run 1 trial at a time.
tuner = tune.Tuner(tune.with_resources(trainable, {"cpu": 2, "gpu": 1}), tune_config=tune.TuneConfig(num_samples=10))
results = tuner.fit()
  1. indent continued code blocks to increase legibility:
# If you have 8 GPUs, this will run 8 trials at once.
tuner = tune.Tuner(
    tune.with_resources(trainable, {"gpu": 1}),
    tune_config=tune.TuneConfig(num_samples=10)
)
results = tuner.fit())
  1. assign variables outside of function calls to emphasize what the in-line function calls represent:
trainable_with_resources = tune.with_resources(trainable, {"gpu": 1})    # or some other name
tuner = tune.Tuner(trainable_with_resources, tune_config=tune.TuneConfig(num_samples=10))
results = tuner.fit())
@matthewdeng matthewdeng added good first issue Great starter issue for someone just starting to contribute to Ray tune Tune-related issues P2 Important issue, but not time-critical air labels Aug 31, 2022
@matthewdeng
Copy link
Contributor

Thanks for flagging this! @justinvyu can you take this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Great starter issue for someone just starting to contribute to Ray P2 Important issue, but not time-critical tune Tune-related issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants