google-colaboratory - 在 Google Colab 上设置 MLflow

标签 google-colaboratory mlflow mlops

我经常使用 Google Colab 来训练 TF/PyTorch 模型,因为 Colab 为我提供了 GPU/TPU 运行时。此外,我喜欢使用 MLflow 来存储和比较训练模型、跟踪进度、共享等。将 MLflow 与 Google Colab 一起使用有哪些可用的解决方案?

最佳答案

有一个Github issue关于这一点,尽管在撰写本文时它仍然是开放的 [编辑:刚刚关闭],贡献者 dmatrix 很友好地提供了 notebook提供完整的解决方案,使用 pyngrok .
这是代码(旨在在 Colab 笔记本上运行),在此处使用隐式 permission of the author 重新发布:

!pip install mlflow --quiet
!pip install pyngrok --quiet

import mlflow

with mlflow.start_run(run_name="MLflow on Colab"):
  mlflow.log_metric("m1", 2.0)
  mlflow.log_param("p1", "mlflow-colab")

# run tracking UI in the background
get_ipython().system_raw("mlflow ui --port 5000 &") # run tracking UI in the background


# create remote tunnel using ngrok.com to allow local port access
# borrowed from https://colab.research.google.com/github/alfozan/MLflow-GBRT-demo/blob/master/MLflow-GBRT-demo.ipynb#scrollTo=4h3bKHMYUIG6

from pyngrok import ngrok

# Terminate open tunnels if exist
ngrok.kill()

# Setting the authtoken (optional)
# Get your authtoken from https://dashboard.ngrok.com/auth
NGROK_AUTH_TOKEN = ""
ngrok.set_auth_token(NGROK_AUTH_TOKEN)

# Open an HTTPs tunnel on port 5000 for http://localhost:5000
ngrok_tunnel = ngrok.connect(addr="5000", proto="http", bind_tls=True)
print("MLflow Tracking UI:", ngrok_tunnel.public_url)
其输出将是 pyngrok - 生成的网址如:
MLflow Tracking UI: https://0a23d7a7d0c4.ngrok.io
单击这将导致 MLfLow GUI 屏幕。
(感谢 pyngrok 创建者,Alex Laird 对原始代码的轻微修改)
使用 MLflow 版本 1.10.0 和 1.11.0 进行测试。

关于google-colaboratory - 在 Google Colab 上设置 MLflow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61615818/

相关文章:

google-colaboratory - 如何在 google colab 中使用 JavaScript?

python - 谷歌colab中的for循环列表索引超出范围

python - 使用 MLFlow 执行 GridSearchCV

python - 如何为 mlflow 设置不同的本地目录?

kubernetes - Kubeflow-羽衣甘蓝 :- How to integrate kubeflow-kale extension to run pipelines on a seperate standalone cluster of Kubeflow pipelines

import - 无法从 'rank_zero_only' 导入名称 'pytorch_lightning.utilities.distributed'

python - 为什么 .isascii() 在 google colab 上不起作用?

python - 在没有 Conda 环境的情况下部署 MLflow 模型

git - 是否有必要从我们的 CI 管道提交 DVC 文件?

azure - 使用 Devops 的自定义环境运行 Azure ML 作业时出现磁盘已满错误