MLflow tracking or Tensorboard are great to visualize the results of experiments running on a remote server. Actually they’re great to keep track of any sort of computation involving repeated runs with changing parameters, not just machine learning runs.

To open the UI in the browser of a local machine, you can use SSH port forwarding. If you already have a VS Code window open, the embedded terminal automates port forwarding after you type the command. To make things even simpler, I call ssh with some extra commands directly from my local terminal, so I just have to type (or copy-paste from this webpage) a single line.

Here is my one-liner:

ssh -L 5003:127.0.0.1:5003 example.com "source ~/.cache/pypoetry/virtualenvs/example-D6FNjH1C-py3.8/bin/activate; mlflow ui --backend-store-uri file:////example/logs/mlflow/ --port 5003"

Variants

  • Of course you can replace mlflow ui --backend-store-uri file:////example/logs/mlflow/ by tensorboard --logdir='./tensorboard_dir' if you prefer Tensorboard.
  • If you don’t have a domain name, you can put the IP adress of your remote machine instead of example.com.
  • If your MLflow instance is already running you’ll get something like [ERROR] Connection in use: ('127.0.0.1', 5003). You don’t need to start it again, so you can just SSH with port forwarding: ssh -L 5003:127.0.0.1:5003 example.com (without the extra command).
  • If you use a Conda environment instead of Poetry, or any other sort of virtual environment, you can activate it by sourcing the right file such as:

ssh -L 5003:127.0.0.1:5003 12.123.45.67 "source ~/.miniconda/etc/profile.d/conda.sh; conda activate myenv; mlflow ui --backend-store-uri file:///$HOME/myproject/logs/mlruns --port 5003"