パッケージ化とコンテナ化

End-to-End Machine Learning

Joshua Stapleton

Machine Learning Engineer

デプロイとコンテナ化

デプロイ

  • モデル+依存関係をユニットに梱包
  • 異なる環境で実行
  • コンテナ化とデプロイの事実上の標準はDocker

機械学習ライフサイクルのデプロイ段階

End-to-End Machine Learning

Docker

  • コンテナで開発を簡素化するプラットフォーム

コンテナ:

  • アプリを単体の資産として梱包
  • プラットフォーム非依存に設計
  • Get Docker

 

DataCampのDockerコース

Dockerロゴ

End-to-End 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
End-to-End 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 .
End-to-End Machine Learning

コンテナのタグ付け

タグ付け:

docker tag heart_disease_model:latest heart_disease_model:1.0
  • イメージ/コンテナの識別・管理が容易に
  • 詳細で堅牢なモデルレジストリを維持
  • タグ付け後、デプロイ準備完了

矢印で表したデプロイ

End-to-End Machine Learning

ベストプラクティス

Dockerでモデルのパッケージ化は容易ですが…

  • セキュリティを意識
  • 機密データは含めない
  • 信頼できる(検証済み)イメージを使用

アプリに機密情報がある場合は

  • 環境変数を使用
  • 例: 接続文字列/パスワード

セキュリティロック

End-to-End Machine Learning

練習しましょう!

End-to-End Machine Learning

Preparing Video For Download...