Displaying and Saving the Best Trial During Hyperparameter Search with Optuna in Parallel GPU Environment

Issue

I am conducting hyperparameter optimization using Optuna integrated into the PyTorch Imagenet example, while parallelizing across GPUs. However, I am unsure how to display and save the results of the best trial (optimal trial).

Details

I am using the study.optimize method from Optuna as shown in the code below. mp.spawn is utilized to distribute the workload across each GPU. The issue arises in capturing and saving the results of the best trial while maintaining GPU parallelization. How can this be achieved?

study.optimize(
    lambda trial: mp.spawn(
        objective, args=(ngpus_per_node, args, trial), nprocs=ngpus_per_node
    ),
    n_trials=100,
)

def objective(gpu, ngpus_per_node, args, trial):
    return main_worker(gpu, ngpus_per_node, args, trial)

Question

What is the recommended approach to display and save the best trial while performing hyperparameter search with GPU parallelization using Optuna? Is there a specific method or practice within Optuna or PyTorch that facilitates this?