Search code examples
pythonmlflowmlops

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


I was running ML experiments on a ssh server, the experiments were logged via mlflow and stored in local mlruns on the server.

The code were just basic usage of mlflow and looks like this

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')

Now I want to see the logged metrics and artifactos from my own laptop, so I tried

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

However, it looks like nothing showed in localhost:8888 on my own laptop.

Anything I did wrong about the code and mlflow ui command?


Solution

    • Run mlflow on a remote server
    mlflow server --host 0.0.0.0 --port 8888
    
    LocalForward 8888 your_remote_machine_addr:8888
    
    • Connect to localhost:8888 on your browser