如何通过 `mlflow ui` 查看在其他服务器上登录的实验的结果?

How to see results via `mlflow ui` for experiments logged on a other server?

我在 ssh 服务器上进行了 运行 ML 实验,实验通过 mlflow 记录并存储在服务器的本地 mlruns 中。

代码只是 mlflow 的基本用法,看起来像这样

import numpy as np
import mlflow
import matplotlib.pyplot as plt

from pathlib import Path
from sklearn.linear_model import LinearRegression
from sklearn.metrics import r2_score


if __name__ == '__main__':
    Path('./plot').mkdir(exist_ok = True)
    mlflow.set_experiment('demo-exp')
    with mlflow.start_run():
        x     = np.random.randn(10, 1)
        y     = np.random.randn(10, 1)
        model = LinearRegression().fit(x, y)
        py    = model.predict(x)
        r2    = r2_score(y, py)
        plt.plot(y, py, '+')
        plt.savefig('./plot/result.png')
        plt.close()

        mlflow.log_metric('r2', r2)
        mlflow.log_artifact('./plot/result.png')

现在我想从我自己的笔记本电脑上查看记录的指标和工件,所以我尝试了

mlflow ui \
    --default-artifact-root=sftp:///USER_NAME@ADDRESS/path/to/experiment/mlruns \
    --port=8888 \

但是,在我自己的笔记本电脑上 localhost:8888 中似乎没有任何显示。

我在代码和 mlflow ui 命令方面做错了什么?

  • 运行 远程服务器上的 mlflow
mlflow server --host 0.0.0.0 --port 8888
  • 在本地计算机上配置 ssh 本地端口转发,如下所示: SSH Port forwarding in a ~/.ssh/config file?
LocalForward 8888 your_remote_machine_addr:8888
  • 在您的浏览器上连接到 localhost:8888