diff --git a/beginner_source/hyperparameter_tuning_tutorial.py b/beginner_source/hyperparameter_tuning_tutorial.py index e9141b45472..88d08ec3c05 100644 --- a/beginner_source/hyperparameter_tuning_tutorial.py +++ b/beginner_source/hyperparameter_tuning_tutorial.py @@ -48,10 +48,21 @@ from torch.utils.data import random_split import torchvision import torchvision.transforms as transforms +# sphinx_gallery_start_ignore +# Fixes ``AttributeError: '_LoggingTee' object has no attribute 'fileno'``. +# This is only needed to run with sphinx-build. +import sys +if not hasattr(sys.stdout, "encoding"): + sys.stdout.encoding = "latin1" + sys.stdout.fileno = lambda: 0 +# sphinx_gallery_end_ignore from ray import tune from ray.air import Checkpoint, session from ray.tune.schedulers import ASHAScheduler +# TODO: Migrate to ray.train.Checkpoint and remove following line +os.environ["RAY_AIR_NEW_PERSISTENCE_MODE"]="0" + ###################################################################### # Most of the imports are needed for building the PyTorch model. Only the last three # imports are for Ray Tune. @@ -448,13 +459,6 @@ def main(num_samples=10, max_num_epochs=10, gpus_per_trial=2): if __name__ == "__main__": - # sphinx_gallery_start_ignore - # Fixes ``AttributeError: '_LoggingTee' object has no attribute 'fileno'``. - # This is only needed to run with sphinx-build. - import sys - - sys.stdout.fileno = lambda: False - # sphinx_gallery_end_ignore # You can change the number of GPUs per trial here: main(num_samples=10, max_num_epochs=10, gpus_per_trial=0) diff --git a/requirements.txt b/requirements.txt index d93af015859..2aa065fd241 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,7 +20,7 @@ bs4 awscliv2==2.1.1 flask spacy==3.4.1 -ray[tune]==2.4.0 +ray[tune]==2.7.2 tensorboard jinja2==3.1.3 pytorch-lightning