我最近开始使用 Metaflow 进行超参数搜索。我对所有参数使用 foreach
,如下所示:
from metaflow import FlowSpec, step
@step
def start_hpo(self):
self.next(self.train_model, foreach='hpo_parameters')
@step
def train_model(self):
# Trains model...
这可以正常工作,因为它按预期启动步骤train_model
,但不幸的是它想要立即并行所有步骤。这会导致我的 GPU/CPU 立即耗尽内存,导致该步骤失败。
有没有办法告诉metaflow线性执行这些步骤/一次一个或其他解决方法?
谢谢
最佳答案
@BBQuercus 您可以使用 --max-workers
标志来限制并行化。
目前,我们并行运行的任务不超过 16 个,您可以将其覆盖为 python myflow.py run --max-workers 32
。
关于python - 停止 Metaflow 并行化 foreach 步骤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60053025/