패키징과 컨테이너화

엔드 투 엔드 Machine Learning

Joshua Stapleton

Machine Learning Engineer

배포와 컨테이너화

배포

  • 모델과 종속성을 하나의 유닛으로 패키징
  • 다양한 환경에서 실행 가능하게 함
  • 컨테이너화/배포의 사실상 표준: Docker

머신러닝 라이프사이클의 배포 단계

엔드 투 엔드 Machine Learning

Docker

  • 컨테이너로 개발을 단순화하는 플랫폼

컨테이너:

  • 애플리케이션을 독립 실행형 자산으로 패키징
  • 플랫폼 독립적으로 설계됨
  • Docker 받기

 

DataCamp Docker 코스

Docker 로고

엔드 투 엔드 Machine Learning

Docker 사용 1부

Dockerfile: 컨테이너 빌드 지침

# Use an official Python runtime as a parent image
FROM Python:3.7

# Set the working directory in the container to /app WORKDIR /ML_pipeline
# Copy the current directory contents into the container at /app ADD . /ML_pipeline
# Install any needed packages specified in requirements.txt RUN pip install --no-cache-dir -r requirements.txt
엔드 투 엔드 Machine Learning

Docker 사용 2부

# ... continued
# Make port 80 available to the world outside this container
EXPOSE 80
# Define environment variable
ENV NAME World
# Run app.py when the container launches
CMD ["Python", "ML_pipeline.py"]

정의한 이미지 빌드:

docker build -t heart_disease_model .
엔드 투 엔드 Machine Learning

컨테이너 태깅

태깅:

docker tag heart_disease_model:latest heart_disease_model:1.0
  • 이미지/컨테이너 식별·관리 용이
  • 상세하고 견고한 모델 레지스트리 유지에 도움
  • 태깅 후 배포 준비 완료!

화살표로 시각화한 배포

엔드 투 엔드 Machine Learning

모범 사례

Docker로 모델 패키징은 쉽지만...

  • 보안을 최우선으로
  • 민감 데이터 포함 금지
  • 신뢰할 수 있는(검증된) 이미지 사용

애플리케이션에 민감 정보가 있다면...

  • 환경 변수 사용
  • 예: 연결 문자열/비밀번호

보안 자물쇠

엔드 투 엔드 Machine Learning

연습해 봅시다!

엔드 투 엔드 Machine Learning

Preparing Video For Download...