专业编程基础技术教程

网站首页 > 基础教程 正文

CentOS 9 下 MLFlow 官方 Totorial 详解 : (二) ML Flow Docker 容器化部署

ccvgpt 2025-05-15 16:48:45 基础教程 16 ℃

CentOS 9, 安装 Docker

CentOS 9 系统Docker安装步骤,请参照文章: CentOS 9 dnf 安装 Docker, 配置阿里云 Docker 镜像(
https://www.toutiao.com/article/7503392130052669993/)

mlflow Dockerfile

# Use an official Miniconda runtime as a parent image
FROM continuumio/miniconda3

# Set the working directory in the container
WORKDIR /NN

# Copy the current directory contents into the container at /NN
COPY . /NN

# Configure Conda to use the Tsinghua mirror
RUN conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
RUN conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
RUN conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
RUN conda config --set show_channel_urls yes

# Create a Conda environment
RUN conda create -n mlflow_env python=3.10 -y

# Activate the Conda environment
ENV PATH=/opt/conda/envs/mlflow_env/bin:$PATH

# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Export the installed package versions to requirements.txt
RUN pip freeze > requirements.txt

# Make port 5001 available to the world outside this container
EXPOSE 5001

# Define environment variable
ENV NAME=Dev

# Run app.py when the container launches
CMD ["mlflow", "server", "--host", "0.0.0.0", "--port", "5001"]

requirements.txt内容如下:

CentOS 9 下 MLFlow 官方 Totorial 详解 : (二) ML Flow Docker 容器化部署

mlflow==2.17.2
numpy
matplotlib
scikit-learn

编译 Docker 镜像

sudo docker build -t mlflow_py310:2.17.2 .

运行 Docker容器

 sudo docker run -p 5001:5001 -v $(pwd):/app -v $(pwd)/mlruns:/app/mlruns mlflow_py310:2.17.2

# sudo docker exec -it 61adaef519c5 /bin/bash

Tags:

最近发表
标签列表