【问题标题】:mlflow Exception: Run with UUID is already activemlflow 异常:使用 UUID 运行已处于活动状态
【发布时间】:2021-11-24 21:39:03
【问题描述】:

使用 mlflow.set_tracking_uri 设置 tracking_uri 和 set_experiment,遇到错误并检查以再次运行以下代码。收到“异常:使用 UUID 运行已处于活动状态”的错误。 尝试使用mlflow.end_run 结束当前运行,但得到 RestException: RESOURCE_DOES_NOT_EXIST: Run UUID not found。 目前卡在这个无限循环中。有什么建议吗?

    mlflow.set_experiment("my_experiment")
    mlflow.start_run(run_name='my_project')
    mlflow.set_tag('input_len',len(input))
    mlflow.log_param('metrics', r2)

【问题讨论】:

  • 最后重启 Jupyter notebook 内核。再次运行,就可以了。
  • 通常,mlflow.end_run() 命令可以缓解这种情况。但是,根据我的经验,它并不总是有效,并且必须在某个地方有锁......

标签: mlflow


【解决方案1】:

我的情况略有不同,但我在此处发布解决方案,以防它有助于此线程的新手。我不小心设置了运行标签之前开始运行

mlflow.set_experiment('my_experiment')
mlflow.set_tag('input_len', len(input))  # Auto-creates a run ID
mlflow.start_run(run_name='my_project')  # Tries to name the same run, throwing error

确保start_run 在所有其他日志记录/标签解决问题之前出现

【讨论】:

    【解决方案2】:

    就我而言,我在 set_tracking_uri() 之后使用 mlflow.get_artifact_uri()。

    Mlflow 为 get_artifact_uri() 函数创建一个运行,当我们再次尝试开始运行时,它会抛出上述异常。

    错误代码

    mlflow.set_tracking_uri("http://localhost:5000")
    mlflow.set_experiment('Exp1')
    print('artifact uri:', mlflow.get_artifact_uri())
    
    with mlflow.start_run():
        mlflow.log_param('SIZE',100)        
    
    Exception: Run with UUID f7d3c1318eeb403cbcf6545b061654e1 is already active. To start a new run, first end the current run with mlflow.end_run(). To start a nested run, call start_run with nested=True
    

    所以 get_artifact_uri() 必须在 start_run 内容中使用。并且成功了。

    工作代码

    mlflow.set_tracking_uri("http://localhost:5000")
    mlflow.set_experiment('Exp1')
    
    with mlflow.start_run():
        print('artifact uri:', mlflow.get_artifact_uri())
        mlflow.log_param('SIZE',100)    
    

    【讨论】:

      猜你喜欢
      • 2016-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-16
      • 1970-01-01
      • 1970-01-01
      • 2016-06-18
      • 1970-01-01
      相关资源
      最近更新 更多