본문 바로가기

카테고리 없음

MlFlow Remote Server setting

https://github.com/mlflow/mlflow

 

GitHub - mlflow/mlflow: Open source platform for the machine learning lifecycle

Open source platform for the machine learning lifecycle - mlflow/mlflow

github.com

 

  • Dockerfile - docker-compose.yml 파일 생성 - 빌드 - compose up 순으로 진행
  • artifact는 마운트된 nfs 폴더에 저장

 

Dockerfile

# Use the official MLflow image
FROM ghcr.io/mlflow/mlflow:latest

# Install psycopg2 and any other dependencies
RUN pip install psycopg2-binary

# Install netcat (nc) to check PostgreSQL readiness
# postgresql의 up 속도가 느린 관계로 up 상태 확인 후 연결
RUN apt-get update && apt-get install -y netcat

CMD ["mlflow", "server"]

 

 

Docker-compose.yml

version: '3.8'

services:
  postgres:
    image: postgres:13
    container_name: postgres
    restart: always
    environment:
      POSTGRES_USER: mlflow
      POSTGRES_PASSWORD: mlflowpass
      POSTGRES_DB: mlflow_db
    volumes:
      - ./postgres-data:/var/lib/postgresql/data
    ports:
      - "5433:5432"  # Host: 5433 -> Container: 5432
    networks:
      - mlflow_net

  mlflow:
    build: .
    container_name: mlflow_server
    restart: always
    ports:
      - "5000:5000"
    depends_on:
      - postgres
    environment:
      MLFLOW_TRACKING_URI: http://127.0.0.1:5000
      MLFLOW_BACKEND_STORE_URI: postgresql://mlflow:mlflowpass@postgres:5432/mlflow_db
    command: >
      /bin/sh -c "
      echo 'Waiting for PostgreSQL to be ready...' &&
      until nc -z postgres 5432; do sleep 2; done &&
      echo 'PostgreSQL is up, starting MLflow...' &&
      mlflow server
      --host 0.0.0.0
      --port 5000
      --backend-store-uri postgresql://mlflow:mlflowpass@postgres:5432/mlflow_db
      --default-artifact-root /mnt/shared"
      #nginx를 통해 reverse proxy 및 domain 연결할때 사용
      #그 외 경우 아래 파라미터 주석
      --app-name /mlflow/ 
    volumes:
      - /mnt/shared:/mnt/shared
    networks:
      - mlflow_net

networks:
  mlflow_net:

 

같은 디렉토리에 위치한 후 빌드

 

sudo docker compose build --no-cache

 

docker compose up

 

#background로 docker-compose.yml 실행
sudo docker compose up -d

 

*down이 필요할 경우

 

sudo docker compose down --volumes --remove-orphans

 

http://127.0.0.1:5000을 통해 mlflow 접속 #docker-compose.yml 파일 --app-name 주석처리