Upgrade to Pro — share decks privately, control downloads, hide ads and more …

2021-10-23 Amazon SagaMaker with MLflow

Avatar for Naka Masato Naka Masato
October 23, 2021

2021-10-23 Amazon SagaMaker with MLflow

Avatar for Naka Masato

Naka Masato

October 23, 2021
Tweet

More Decks by Naka Masato

Other Decks in Technology

Transcript

  1. 今日の内容 1. MLflow の簡単な紹介 2. MLflow を ECS+Fargate 上で動かす 3.

    MLflow と SageMaker の連携 前回 : 1. SageMaker Notebook を AWS コンソール上から作成 2. モデル作成・学習・デプロイ → 試行錯誤した実験、モデル、コードをより統一して管理したい
  2. MLflowとは 4 つのコンポーネント : 1. MLflow Tracking: 実験のトラックを可能に 2. MLflow

    Projects: コードの再現性 (version, library, parameter,..) 3. MLflow Models: モデルのパッケージとデプロイ 方法の統一 4. MLflow Registry: モデル管理 ML のライフサイクル全体を統一して管理できる!
  3. MLflowを使う場合の選択肢 1. Managed MLflow by Databricks a. Notebook integration b.

    Scalability c. Role-based access control 2. Open Source MLflow a. 自分でホストする必要あり b. Notebook も別途構築の必要あり c. アクセスコントロールはサポートされていない 本番運用を考慮すると、 Managed にしたほうが楽+ ML の中身に集中はできそう
  4. MLflowをAWS上で簡単に動かす マニュアルに設定しようとすると結構たいへん 1. VPC 、 Subnets などの Networking の設定 2.

    動かすマシンの準備 (EC2, EKS, ECS….) 3. Backend store (MySQL など ) や Artifact store (S3) の準備 4. MLflow のデプロイ + 接続確認 … 紹介 : AWS Machine Leaning Blog (2021 Jan) https://aws.amazon.com/blogs/machine-learning/managing-your-mac hine-learning-lifecycle-with-mlflow-and-amazon-sagemaker/
  5. Architecture (MLflow on ECS using Fargate + SageMaker) 1. MLflow

    をコンテナ化して、 ECS というマネージ ドのコンテナサービスの上で動かす a. → MLflow 自体の安定性・監視・スケーラビリティを担 保 2. RDS を Backend store に、 S3 を Artifact store に 保存 a. メタデータやモデルなどを安全に管理 3. Load Balancer で MLflow の Remote から使用で きる
  6. 簡単にDeployするTool: AWS CDK AWS CDK (Cloud Development Kit) 利点 1.

    Setup が簡単 ! a. npm install -g aws-cdk 2. インフラがコード (python, ts, ...) で書かれている ! a. 今回の例も : https://github.com/aws-samples/amazon-sagemaker-mlfl ow-fargate 3. aws-samples に例が沢山あるので、体験したいだ けなら複雑な構成も一発で試せる ! a. aws-cdk deploy Python で記述した例
  7. Deployステップ Step: 1. Git Clone 2. Python のライブラリインストール 3. デプロイ

    25 分くらいで MLflow on ECS with Fargate + RDS + S3 完成 !!! 👏👏
  8. 今回のBlog例の難点 • Security ◦ Public Load Balancer を MLflow に使用しているため誰

    でもアクセスできてしまう‥ • SageMaker ◦ CDK に含まれていないため、 自分で別途建てる必要あり ..
  9. しかし! 新しい CDK aws-mlflow-sagemaker-cdk登場! 2021/10/14 に新しい CDK が ! https://github.com/aws-samples/aws-mlflo

    w-sagemaker-cdk 一つの Deploy で 2 つまとめて建てられる! 1. MLflow on ECS using Fargate (RDS と S3 の連携込み ) 2. SageMaker さらに今回は MLflow の Endpoint は internal! ( 安全 !)
  10. 問題: InternalだからMLflow UIアクセスできない… 1. MLflow UI は MLflow VPC の中

    2. MLflow VPC は Private Link で SageMaker VPC からのアクセスだけ 許可 → Users が MLflow UI にアクセス出来な い !! AWS に Client VPN というものが ! MLflow UI はここ
  11. Client VPNを設定 1. AWS Client VPN を設定 a. split-tunnel を

    enable すると Target の CIDR 宛てのトラフィックのみを VPN 経由でルー ティングできる ! ( これしないと無駄にすべ てのトラフィックが VPN 経由となる )
  12. 次回以降: SageMaker Pipelines: the first purpose-built, easy-to-use continuous integration and

    continuous delivery (CI/CD) service for machine learning (ML) Components: 1. pipelines 2. model registry 3. and projects. https://aws.amazon.com/blogs/machine-learning/building-automating-managing-and-sc aling-ml-workflows-using-amazon-sagemaker-pipelines/