Sign inSign up

ocpub/oc9-mlflow

By ocpub

Updated 4 months ago

Image
0

162

ocpub/oc9-mlflow repository overview

MLflow on OpenCloudOS 9

基本信息

  • 框架版本:v3.11.0
  • 基础镜像:opencloudos9-minimal
  • Python 版本:3.11
  • CUDA 版本:N/A

项目简介

MLflow 是一个开源的机器学习生命周期管理平台,主要提供以下能力:

  • 实验追踪(Experiment Tracking)
  • 参数与指标记录
  • Artifact 管理
  • 模型注册(Model Registry)
  • 模型部署(Serving)

本镜像基于 OpenCloudOS 9 构建,提供轻量级 MLflow Tracking Server 运行环境。


构建

docker build -t oc9-mlflow:3.11.0 .

使用示例

查看 MLflow 版本
docker run --rm oc9-mlflow:3.11.0 \
  python3 -c "import mlflow; print(mlflow.__version__)"

启动 MLflow Tracking Server

docker run -d \
  --name mlflow \
  -p 5000:5000 \
  oc9-mlflow:3.11.0

访问:

http://localhost:5000

持久化实验数据

默认情况下,容器中的实验数据会随着容器删除而丢失。

推荐挂载数据目录:

docker run -d \
  --name mlflow \
  -p 5000:5000 \
  -v $(pwd)/mlruns:/mlruns \
  oc9-mlflow:3.11.0 \
  sh -c "mlflow server \
    --backend-store-uri sqlite:///mlruns/mlflow.db \
    --default-artifact-root /mlruns \
    --host 0.0.0.0 \
    --port 5000"

目录说明:

mlruns/
├── mlflow.db
└── artifacts

实验追踪示例

创建示例脚本:

import mlflow
import random

mlflow.set_tracking_uri("http://127.0.0.1:5000")
mlflow.set_experiment("demo-experiment")

with mlflow.start_run():

    mlflow.log_param("learning_rate", 0.01)
    mlflow.log_param("epochs", 10)

    for step in range(10):
        loss = 1.0 / (step + 1)
        accuracy = 0.8 + random.random() * 0.1

        mlflow.log_metric("loss", loss, step=step)
        mlflow.log_metric("accuracy", accuracy, step=step)

    with open("result.txt", "w") as f:
        f.write("training completed")

    mlflow.log_artifact("result.txt")

运行:

python3 train.py

然后访问:

http://localhost:5000

即可查看实验参数、指标和 Artifact。


容器网络使用示例

如果训练任务运行在其他容器中,建议使用 Docker Network。

创建网络:

docker network create mlflow-net

启动 MLflow:

docker run -d \
  --name mlflow \
  --network mlflow-net \
  -p 5000:5000 \
  oc9-mlflow:3.11.0

训练容器中配置:

export MLFLOW_TRACKING_URI=http://mlflow:5000

默认配置

配置项默认值
Host0.0.0.0
Port5000
Working Directory/workspace

已知问题

  • 当前镜像为轻量版,不包含 PyTorch、TensorFlow 等深度学习框架
  • 不包含 CUDA 与 GPU 运行环境
  • Model Serving 场景下,部分依赖需用户自行安装

上游项目

Tag summary

Content type

Image

Digest

sha256:440e3155f

Size

281.8 MB

Last updated

4 months ago

docker pull ocpub/oc9-mlflow:3.11.0