Slide 1

Slide 1 text

kubeflow pipelines概要 2021/12/18 那珂将人

Slide 2

Slide 2 text

自己紹介 名前 那珂将人 経歴 ● アルゴリズムエンジニアとしてレコメンドエンジン開発 ● インフラ基盤整備 GitHub: https://github.com/nakamasato Twitter: https://twitter.com/gymnstcs

Slide 3

Slide 3 text

Kubeflow Pipelinesとは The Kubeflow project: ML workflows を Kubernetes 上でシンプル、ポータブルかつス ケーラブルにためのもの コンポーネント : 1. Central Dashboard 2. Kubeflow Notebooks 3. Kubeflow Pipelines 4. KFServing 5. Katib 6. Training Operator 7. Multi-Tenancy https://www.kubeflow.org/ より

Slide 4

Slide 4 text

Kubeflow Pipelinesとは Kubernetes 上で動かす Machine Learning のワークフロー a platform for building and deploying portable, scalable machine learning (ML) workflows based on Docker containers. Goals: 1. End-to-end orchestration: ML パイプラインの全てをカバー 2. Easy experimentation: 簡単に試行錯誤できる 3. Easy re-use: 簡単に再利用できる

Slide 5

Slide 5 text

Kubeflow PipelinesのConcepts 1. Pipeline: 定義 2. Component: Pipeline 内のステップ定義 3. Graph 4. Experiment 5. Run and Recurring Run: Pipeline の実行 6. Run Trigger 7. Step: Component の実行 8. Output Artifact 9. ML Metadata Pipeline がクラス定義で、 Run はインスタンスみた いなイメージ。実行のたびに、 Run オブジェクトが 作成される Pipeline Component Component Run Step Step Run Step Step 実行 実行

Slide 6

Slide 6 text

Kubeflow PipelinesのConceptsとKubernetesの対応 Pipeline Component Component Run Step Step Run Argoの Workflowと いうAPI object Step KubernetesのPod Kubernetes 上 Kubeflow Pipelines の Concepts Pipeline ArgoのWorkflowの manifest file

Slide 7

Slide 7 text

Argo Workflows (ちょっとだけ脱線) Workflow の内部では、 Argo Workflows が使われている Argo Workflows is an open source container-native workflow engine for orchestrating parallel jobs on Kubernetes. Argo Workflows is implemented as a Kubernetes CRD. https://argoproj.github.io/workflows/ Argo Workflows の UI

Slide 8

Slide 8 text

Kubeflow Pipelinesの使用ステップ Steps: 1. Pipeline の定義 : a. Python のスクリプト作成 (SDK kfp を利用 ) 2. Pipeline の実行 a. SDK の kfp.Client を利用して Python から Pipeline を実行 または b. yaml を出力して UI に Upload してから、 UI 上か ら ”Create Run” する 3. Pipeline の状況確認 a. UI 上から確認 b. ( 必要に応じて Kubernetes の Pod などを確認 ) https://www.kubeflow.org/docs/components/pipelines/introduction/ より Kubeflow Pipelines のアーキテクチャ

Slide 9

Slide 9 text

他のMLツールとの簡単な比較 (主観的な印象) 1. AWS SageMaker a. ローカルの Jupyter 環境 → クラウドリソース上で簡単に✅ b. 分析から ML API デプロイまでが簡単✅ c. 実行環境メインのスタート i. Inference, Edge Manager など他にも様々な機能 ( 未検証 ) ii. モデルの管理はちょっと苦手🔺 ? ← MLflow との親和性 2. MLflow a. バラバラになる ML の試行錯誤をまとめる b. モデルの管理とデプロイを統一 c. 実行環境はスコープ外→ローカル✅、クラウド✅ ← SageMaker などとの親和性 3. Kubeflow a. Pipelines i. 拡張機能が豊富な Kubernetes を活用して、コンピュートリソースと ML Pipelines の管理を統一 (End-to-End Orchestration) ii. まるごと全環境 Kubernetes 内で管理 ✅ 管理には Kubernetes の知見が必要🔺 b. 他 : KFServing, Notebooks… 今まで勉強会で共有してきたもの・範囲し か入ってないので考慮で来てない部分が ある

Slide 10

Slide 10 text

Sample: パイプラインの紹介 作るパイプライン : 1. CSV を URL からダウンロードして tar を data 以下に開封 2. 中にある全ての csv ファイルを pandas の DataFrame に読み込む パイプライン : 2-step pipeline 1. download → kfp.components.load_coponent_from_url を使う 2. merge → kfp.components.create_component_from_func と自分の作成した関数に より作成

Slide 11

Slide 11 text

Sample: Pipeline内の2つのComponents 1. download a. kfp.components.load_coponent_from_url を使う 2. merge a. kfp.components.create_component_from_func と自分の作 成した関数により作成

Slide 12

Slide 12 text

Sample: Pipeline用の関数 pipeline 用の関数を作成

Slide 13

Slide 13 text

Sample: Pipelineの実行 2 つの方法 : 1. yaml ファイルに出力してから Upload して UI から実行する 2. SDK から kfp.Client を用いて Python スクリプト内から実行する

Slide 14

Slide 14 text

Demo: Sampleパイプラインの実行

Slide 15

Slide 15 text

まとめ 1. Kubeflow pipelines の基本的なコンポーネントと役割の理解 2. Kubeflow pipelines でのサンプルパイプラインの作成と実行 ToDo 1. Kubeflow Pipelines の実践 2. KFServing などの他のコンポーネントの活用

Slide 16

Slide 16 text

Reference 1. https://www.kubeflow.org/ 2. https://www.kubeflow.org/docs/components/pipelines/introduction/ 3. https://argoproj.github.io/workflows/ 4. https://raw.githubusercontent.com/kubeflow/pipelines/master/components/web/D ownload/component.yaml 5. https://raw.githubusercontent.com/nakamasato/kubeflow-training/main/03-create- first-pipeline/component.yaml 6. https://kubeflow-pipelines.readthedocs.io/en/latest/source/kfp.compiler.html

Slide 17

Slide 17 text

Kubeflow Pipelinesでデプロイされるcomponents 1. workflow-controller <- argo workflows 2. mysql 3. ml-pipeline 4. cache-deployer 5. cache-server 6. metadata-envoy 7. metadata-grpc 8. metadata-writer 9. minio 10. ml-pipeline 11. ml-pipeline-persistenceagent 12. ml-pipeline-scheduledworkflow 13. ml-pipeline-ui 14. ml-pipeline-viewer-crd 15. ml-pipeline-visualizationserver