@@ -417,7 +417,7 @@ def test_accuracy(net, device="cpu", data_dir=None):
417417#
418418# tune.with_resources(
419419# partial(train_cifar, data_dir=data_dir),
420- # resources={"cpu": 2 , "gpu": gpus_per_trial}
420+ # resources={"cpu": cpus_per_trial , "gpu": gpus_per_trial}
421421# )
422422#
423423# Ray Tune automatically manages the placement of these trials and ensures
@@ -447,7 +447,7 @@ def test_accuracy(net, device="cpu", data_dir=None):
447447# tuner = tune.Tuner(
448448# tune.with_resources(
449449# partial(train_cifar, data_dir=data_dir),
450- # resources={"cpu": 2 , "gpu": gpus_per_trial}
450+ # resources={"cpu": cpus_per_trial , "gpu": gpus_per_trial}
451451# ),
452452# tune_config=tune.TuneConfig(
453453# metric="loss",
@@ -465,7 +465,7 @@ def test_accuracy(net, device="cpu", data_dir=None):
465465# Putting it all together
466466# -----------------------
467467
468- def main (num_trials = 10 , max_num_epochs = 10 , gpus_per_trial = 0 ):
468+ def main (num_trials = 10 , max_num_epochs = 10 , gpus_per_trial = 0 , cpus_per_trial = 2 ):
469469 print ("Starting hyperparameter tuning." )
470470 ray .init ()
471471
@@ -488,7 +488,7 @@ def main(num_trials=10, max_num_epochs=10, gpus_per_trial=0):
488488 tuner = tune .Tuner (
489489 tune .with_resources (
490490 partial (train_cifar , data_dir = data_dir ),
491- resources = {"cpu" : 2 , "gpu" : gpus_per_trial }
491+ resources = {"cpu" : cpus_per_trial , "gpu" : gpus_per_trial }
492492 ),
493493 tune_config = tune .TuneConfig (
494494 metric = "loss" ,
0 commit comments