Ray Tune因多次跑步而陷入困境



嗨,我正在尝试使用ray tune进行超参数优化。下面是我的代码实现。

然而,我陷入了困境,即使没有任何错误消息,也无法返回结果。

@ray.remote
def main:
do_somthing
return loss
def ray_pick_best_hypter(config):
runs = 10
loss_avg = np.mean(ray.get([main.remote(config,run=x) for x in range(runs)]))
tune.report(loss_avg=loss_avg)
config = load_config()
analysis = ray.tune.run(ray_pick_best_hypter, config=config,progress_reporter=reporter)

下面的代码运行良好,但我想运行多个实验并获得平均值。


def ray_pick_best_hypter(config):
loss_avg = ray.get([main.remote(config,run=x))
tune.report(loss_avg=loss_avg)

代码中的问题是什么?

您似乎正在从可培训内容中启动多个分布式培训过程。对main.remote()的每次调用都将启动一个新的分布式任务。由于你同时启动其中10个,它们会尝试并行运行。然而,每次试用的默认资源分配通常只有1个CPU,因此无法安排远程任务。

要解决这个问题,你可以通过resources_per_trial={"cpu": 11}——这样你的每个远程任务都会有自己的CPU运行

最新更新