Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

not able to dockerize mlflow

Tags:

docker

mlflow

while dockerizing mlflow , only .trash is getting created beacuse of that in mlflow ui , getting error as "no experiments exists"

dockerfile

FROM python:3.7.0

RUN pip install mlflow==1.0.0

WORKDIR /data

EXPOSE 5000

CMD mlflow server \
    --backend-store-uri /data/ \
    --default-artifact-root /data/ \
    --host 0.0.0.0

docker compose :

  mlflow:
    # builds track_ml Dockerfile
    build:
      context: ./mlflow_dockerfile
    expose: 
      - "5000"
    ports:
      - "5000:5000"
    volumes: 
      - ./data:/data
like image 340
Akash Dubey Avatar asked Sep 06 '19 06:09

Akash Dubey


1 Answers

You can use this Dockerfile, Taken from mlflow-workshop which is more generic and support different ENV to debug and working with different version.

By default it will store the artifacts and files inside /opt/mlflow. It's possible to define the following variables:

MLFLOW_HOME (/opt/mlflow)
MLFLOW_VERSION (0.7.0)
SERVER_PORT (5000)
SERVER_HOST (0.0.0.0)
FILE_STORE (${MLFLOW_HOME}/fileStore)
ARTIFACT_STORE (${MLFLOW_HOME}/artifactStore)

Dockerfile

FROM python:3.7.0
LABEL maintainer="Albert Franzi"

ENV MLFLOW_HOME /opt/mlflow
ENV MLFLOW_VERSION 0.7.0
ENV SERVER_PORT 5000
ENV SERVER_HOST 0.0.0.0
ENV FILE_STORE ${MLFLOW_HOME}/fileStore
ENV ARTIFACT_STORE ${MLFLOW_HOME}/artifactStore

RUN pip install mlflow==${MLFLOW_VERSION} && \
    mkdir -p ${MLFLOW_HOME}/scripts && \
    mkdir -p ${FILE_STORE} && \
    mkdir -p ${ARTIFACT_STORE}

COPY scripts/run.sh ${MLFLOW_HOME}/scripts/run.sh
RUN chmod +x ${MLFLOW_HOME}/scripts/run.sh

EXPOSE ${SERVER_PORT}/tcp

VOLUME ["${MLFLOW_HOME}/scripts/", "${FILE_STORE}", "${ARTIFACT_STORE}"]

WORKDIR ${MLFLOW_HOME}

ENTRYPOINT ["./scripts/run.sh"]

scripts/run.sh

#!/bin/sh

mlflow server \
    --file-store $FILE_STORE \
    --default-artifact-root $ARTIFACT_STORE \
    --host $SERVER_HOST \
    --port $SERVER_PORT

Launch MLFlow Tracking Docker

docker build -t my_mflow_image .
docker run -d -p 5000:5000 --name mlflow-tracking my_mflow_image

Run trainings

Since we have our MLflow Tracking docker exposed at 5000, we can log executions by setting the env variable MLFLOW_TRACKING_URI.

MLFLOW_TRACKING_URI=http://localhost:5000 python example.py

Also, better to remove - ./data:/data on first run, debug with out mount, and the suggest dockerfile you might need to mount different path that is mentioned in ENV based on your need.

like image 173
Adiii Avatar answered Nov 01 '22 05:11

Adiii