【问题标题】:MLFlow active run does not match environment run idMLFlow 活动运行与环境运行 ID 不匹配
【发布时间】:2021-05-15 01:18:40
【问题描述】:

我正在尝试执行 MLFlow 运行,但在尝试了很多事情后遇到了以下错误。


run = mlflow.active_run()
if run:
    print("Active run_id: {}".format(run.info.run_id))
    mlflow.end_run()

mlflow.set_experiment('TNF_EXP') 
mlflow.set_tracking_uri("http://localhost:5000/") # Actual Server URI instead of localhost
experiment = mlflow.get_experiment_by_name("TNF_EXP")

with mlflow.start_run(experiment_id=experiment.experiment_id) as run:
...
...

mlflow.end_run()

错误 -

File "/.../ModelTrainer.py", line 108, in train
    with mlflow.start_run(experiment_id=experiment.experiment_id) as run:
  File "/usr/local/lib/python3.6/site-packages/mlflow/tracking/fluent.py", line 207, in start_run
    "arguments".format(existing_run_id)
mlflow.exceptions.MlflowException: Cannot start run with ID e9953eb5918845bb9be1xxxxxx because active run ID does not match environment run ID. Make sure --experiment-name or --experiment-id matches experiment set with set_experiment(), or just use command-line arguments
2021/02/11 09:41:36 ERROR mlflow.cli: === Run (ID 'e9953eb5918845bb9be1xxxxxx') failed ===

我注意到我之前有一个active run,所以我添加了第一个if block 来结束运行。代码成功运行,我能够在 MLFlow UI 上记录数据,但现在当我运行它时,我开始遇到同样的问题。目前在开始新的运行之前没有找到任何活动的运行。

仅供参考,我正在使用代码中提到的相应跟踪 URI 在 Azure 服务器上运行代码。

但是,如果我在 CLI 上的 mlflow run 命令中包含参数 --experiment-name="TNF_EXP",则代码运行良好

【问题讨论】:

    标签: python mlflow


    【解决方案1】:

    这主要是因为您已使用default experiment name 开始运行,然后您尝试将experiment_name 设置为“TNF_EXP”。

    建议您使用mlflow.run(..., experiment_name="TNF_EXP") python 方法,然后从CLI 运行它。

    您可以找到更多信息here。

    【讨论】:

      【解决方案2】:

      MLflow 项目当前支持的行为是使用 mlflow cli 定义实验名称或 id(如果您知道 id)。

      这将需要对 MLflow 项目的执行方式进行系统更改,因为 mlflow run CLI 命令将创建一个主运行(在 --experiment-name 参数或默认值下)。 main 中使用 start_run 创建的嵌套运行需要属于同一个父实验。

      如果您想在特定实验下登录,唯一支持的模型是在 CLI 命令中使用 --experiment-name 或 --experiment-id。

      您现在可以将其运行为:mlflow run。 --experiment-name 测试

      【讨论】:

      • 欢迎来到stackoverflow!您能否为您描述的行为的文档添加来源或链接?
      猜你喜欢
      • 2020-03-19
      • 1970-01-01
      • 1970-01-01
      • 2016-10-14
      • 1970-01-01
      • 1970-01-01
      • 2013-02-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多