Share
Embed
Introduction to Kubeflow 0.1 and future @Cloud Native Meetup Tokyo #2
Introduction to Kubeflow 0.1and future
@Cloud Native Meetup Tokyo #2
Masaya Aoyama @amsy810 (CyberAgent)
KubeCon 2017 NA で発表、KubeCon 2018 EU で 0.1 のリリースが報告された ML 環境を Kubernetes 上で提供する Kubeflow は、ML ワークフローの展開を「シンプル」「ポータブル」「スケーラブル」にするために開発されています。今回は KubeCon 2018 EU での発表を交えながら、ML 関連の検証プロジェクトで検証中の Kubeflow についてお話します。
Masaya Aoyama (@amsy810)
June 01, 2018
Transcript
66 slides
-
Masaya Aoyama CyberAgent adtech studio Introduction to Kubeflow 0.1 and
future @Cloud Native Meetup Tokyo #2 MasayaAoyama @amsy810 -
連載「今こそ始めよう!Kubernetes 入門」 @ThinkIT Japan Container Days v18.04 Keynote 登壇 CKA (CKA-1700-0138-0100)、CKAD
(CKAD-1800-0002-0100) OpenStack Active Technical Contributor Masaya Aoyama (@amsy810) Infrastructure Engineer -
Today’s Agenda 01 What is ML and ML Platform? 02
What is Kubeflow? 03 What is Ksonnet? 04 Kubeflow with Ksonnet 05 Roadmap -
What is ML and ML Platform? Index > What is
ML? What is ML Framework? What is Tensorflow and Distributed TF. ML with DevOps. -
What is Machine Learning (ML)? 機械学習 教師あり学習 人工知能(分野) 教師なし学習 強化学習
深層学習 モデル: Neural Network (CNN, RNN, etc), LSTM, etc. タスク: パターン認識、データマイニング、自然言語処理、etc -
What is Machine Learning (ML)? Machine Learning Supervised Learning AI:
Artificial Intelligence Unsupervised Learning Reinforcement Learning Deep Learning Model: Neural Network (CNN, RNN, etc), LSTM, etc task: Pattern Recognition, Data Mining, Natural Language Problem, etc -
What is ML? 学習済みモデル 5 7 1 or 7 ?
Ex) 手書き文字認識(MNIST) -
What is ML? 学習済みモデル Ex) 手書き文字認識(MNIST) with CNN 入力: 256
個 64*64 の画像のビット数 出力: 10 個 0-9 の識別結果 -
What is ML? モデルの作成 モデルの学習 学習済みモデル • ニューラルネットワークの形状 • 隠れ層の数
• 多次元配列(テンソル)の次元数 • ハイパーパラメータの設定 • モデルの学習 • 実際に大規模な学習データを入力 して、各エッジの重みを計算 • 入力に対して出力が返ってくる -
What is ? • OSS の Deep Learning 用 Library
by Google • Google の自社サービスでも実際に利用 • 数値演算や行列演算を行う演算ライブラリ • GPU/TPU 対応、分散処理対応 • Distributed も可能 • Master, Worker, PS Ref: hIps://github.com/aymericdamien/TensorFlow-Examples -
What is Kubeflow? Index > What is Jupyter Notebook &
Jupyter Hub What is TFJob & TF Operator What is TF Serving What is seldon.io -
What is Kubeflow? Kubeflow は Kubernetes 上での機械学習 (ML) ワークフローの展開を simple,
portable, scalable にする サービスを再作成することではなく、様々なインフラストラクチャに ML用の最適なオープンソースシステムをデプロイするための 簡単な方法を提供するのがゴール Kubernetes が動作している場所であればどこでも、 Kubeflow は実行可能 Ref: hIps://github.com/kubeflow/kubeflow -
Kubeflow at KubeCon [KubeCon 2018 EU] Keynote * 1 Session
* 5 ComunitySession * 2 (Intro, DeepDive) LightningTalk * 1 Ref: hIps://kccnceu18.sched.com/?s=kubeflow [KubeCon 2017 NA] Session * 1 -
# Concept 01 Simple Deta Scientist / ML Engineer の学習コストが低く、
モデルの作成に集中できること 03 Scalable Kubernetes 上でワークロード の負荷分散が可能なこと 02 Portable オンプレミスの Kubernetes と クラウド上の Kubernetes などで ポータビリティを保つこと -
# Principles 01 Open • ML Platform の構築は大きな 挑戦なので協力して成功させる •
コミュニティの全員が機会均等 • テスト・リリースをコミュニティが 決定する 03 Kubernetes Native • K8s 上であれば実行可能 • K8s のコンセプト/API を利用 • K8s に依存したアーキテクチャ で別Platformはサポート無し 02 Low bar; high ceiling • 簡単にはじめられること • ユーザの学習コストが少ない • 抽象化された Kubeflowだけ 学べば良い • システム管理者が複雑な拡張 やカスタマイズが可能 -
What is Notebook? Ref: hIps://qiita.com/taka4sato/items/2c3397ff34c440044978 • データサイエンティスト向けの開発環境 • インタラクティブな Python
• 可視化、コメントの記入などが可能 • Mathematica, MATLAB みたいなもの -
What is ? • Notebook を複数ユーザに提供する基盤 • 認証機能あり • 個々のユーザに
Notebook 環境が起動 • Kube spawner: Pod が作成される • LocalProcess spawner • docker spawner • sudo spawner • systemd spawner $ kubectl get pods jupyter-amsy810 NAME READY STATUS RESTARTS AGE jupyter-amsy810 1/1 Running 0 12m 各ユーザごとに起動 -
What is TFJob (TF Operator)? • TFJob • Custorm Resource
Defini`on • + TFJob Operator • + TFJob Dashboard • 分散実行用にまとめて定義が可能 • Master, Worker, ParameterServer • replicaSpecs[].template は podTemplate -
What is TFJob (TF Operator)? • Docker Image は別途作る必要がある •
Operator が行うのは env: TF_CONFIG の inject • Pod の管理 - env: - name: TF_CONFIG value: '{"cluster":{ "master":["sample-job-master-jthw-0:2222"], "ps":["sample-job-ps-jthw-0:2222"], "worker":[ "sample-job-worker-jthw-0:2222", "sample-job-worker-jthw-1:2222", "sample-job-worker-jthw-2:2222"]}, "task":{ "type":"master", "index":0}, "environment":"cloud"}' -
What is Serving? Load 学習済みモデル Serving Request (input) Response (output)
gRPC • 学習済みモデルを元に入力に対して出力を返す • gRPC over HTTP/2 • REST API over HTTP/1.1 は grpc-gateway などが必要 • hIps://github.com/grpc-ecosystem/grpc-gateway • Tensorflow 形式の model を Load 可能 • 無停止での Model 切り替え -
What is ? • Tensorflow 以外の様々なモデルの Serving が可能 • Python
based models (Tensorflow, Keras, scikit-learn) • Spark models • H2O models • R models • etc? • Enterprise 版も有り -
# Principles 01 Open • ML Platform の構築は大きな 挑戦なので協力して成功させる •
コミュニティの全員が機会均等 • テスト・リリースをコミュニティが 決定する 03 Kubernetes Native • K8s 上であれば実行可能 • K8s のコンセプト/API を利用 • K8s に依存したアーキテクチャ で別Platformはサポート無し 02 Low bar; high ceiling • 簡単にはじめられること • ユーザの学習コストが少ない • 抽象化された Kubeflowだけ 学べば良い • システム管理者が複雑な拡張 やカスタマイズが可能 TFJob by kubeflow -
What is Ksonnet? Index > What is env? What is
component? Step 1: init repository and add env Step 2: Generate component from prototype Step 3: deploy component to env Step +α: set specific param for each env -
What is Ksonnet? JSON テンプレート言語の Jsonnet ベースで K8s Manifest を汎用的に記述し、
簡単に特殊化して各環境に様々なアプリケーションを展開可能 -
What is env? - context: cluster: docker-for-desktop-cluster namespace: default user:
docker-for-desktop name: local-dev - context: cluster: gke_pj_asia-northeast1-a_kf namespace: default user: gke_pj_asia-northeast1-a_kf name: remote-prd 適用する環境のことで Context と同意 -
Deployment Service Deployment Prototype: io.ksonnet.pkg.single-port-deployment Prototype: io.ksonnet.pkg.deployed-service What is Prototype
& Component? 雛形の Prototype から、実体の Component を作成する Deployment Service Deployment Component: sample-component Component: sample-component image replicas servicePort nginx:1.12 3 8080 = = = … image replicas nginx:1.12 3 = = -
Step 1: Init repository & add env # リポジトリの初期化(+ 最初の
env を定義) $ ks init sample-app --context local-dev --env dev # 追加の Env を追加 $ ks env add prd --context remote-prd remote-prd local-dev -
Step 2: generate component from prototype # Prototype からデプロイする Component
を作成 $ ks generate deployed-service sample-component --image nginx:1.12 --type LoadBalancer --replicas 3 --servicePort 8080 --containerPort 80 remote-prd local-dev Deployment Service Prototype: io.ksonnet.pkg.deployed-service image = nginx:1.12 replicas = 3 … Deployment Service Component: sample-component -
Step 3: Deploy component to env # dev 環境にsample-component をデプロイ
$ ks apply dev –c nginx-test # prd 環境にすべての Component をデプロイ $ ks apply prd remote-prd local-dev Deployment Service Prototype: io.ksonnet.pkg.deployed-service Deployment Service image = nginx:1.12 replicas = 3 … Component: sample-component Deployment Service Deployment Service -
Step +α: set specific param for each env # prd
の replicas 数は 5 に設定 $ ks param set sample-component replicas 5 --env prd # dev と prd の環境差を確認 $ ks param diff dev prd COMPONENT PARAM ENV1 ENV2 ========= ===== ==== ==== sample-component replicas 3 5 remote-prd local-dev Deployment Service Prototype: io.ksonnet.pkg.deployed-service Deployment Service image = nginx:1.12 replicas = 3 … Component: sample-component Deployment Service Deployment Service -
Kubeflow with Ksonnet Index > TFJob の展開 Prototype: m-job TFServing
の展開 Prototype: m-serving Kubeflow 自体 (control Plane) の展開 Prototype: kubeflow-core -
TFJob の展開 Prototype: tf-job Prototype: io.ksonnet.pkg.tf-job TFJob TFJob Component: sample-job
image args num_masters num_ps num_workers = = = = = … gcr.io/… null 1 1 3 # 雛形から実体の作成 $ ks generate tf-job sample-job # イメージ・ワーカ数・プログラムに渡すargsなどを指定して起動 $ ks param set sample-job … $ ks apply prd -c sample-job -
TFServing の展開 Prototype: tf-serving Prototype: io.ksonnet.pkg.tf-serving Deployment Component: sample-serving model_path
= … gs://… NFS 上のモデルを利用する場合: hIps://github.com/kubeflow/kubeflow/blob/master/components/k8s-model-server/Serve%20a%20local%20model%20using%20Tensorflow%20Serving.md Service Deployment Service # 雛形から実体の作成 $ ks generate tf-serving sample-serving # モデルの場所を変えて起動 $ ks param set sample-serving model_path gs://… $ ks apply prd -c sample-serving -
Prototype: io.ksonnet.pkg.kubeflow-core Deployment Deployment Deployment StatefulSet CRD … Deployment Deployment
Deployment StatefulSet CRD … cloud = gke(prd) | null(dev) jupyterHubServiceType = LoadBalancer tfAmbassadorServiceType = LoadBalancer tfJobUiServiceType = LoadBalancer … Component: kubeflow-core Kubeflow 自体(Control plane)の展開 Prototype: kubeflow-core -
Includes: CRD tfjob 4 Role 4 Rolebinding 4 ServiceAccount 2
ConfigMap m-job-operator m-job-dashboard ambassador m-hub Deployment StatefulSet + Kubeflow 自体(Control plane)の展開 Prototype: kubeflow-core -
# kubeflow-core の設定可能な値 $ ks prototype describe kubeflow-core REQUIRED PARAMETERS:
--name=<name> Name to give to each of the components [type: string] OPTIONAL PARAMETERS: --namespace=<namespace> Namespace to use for the components --disks=<disks> Comma separated list of Google PD to attach to jupyter environments --cloud=<cloud> String identifying the cloud to customize the deployment for --tfAmbassadorServiceType=<tfAmbassadorServiceType> The service type for the API Gateway --tfJobImage=<tfJobImage> The image for the TfJob controller --tfDefaultImage=<tfDefaultImage> The default image to use for TensorFlow --tfJobUiServiceType=<tfJobUiServiceType> The service type for the UI --jupyterHubServiceType=<jupyterHubServiceType> The service type for Jupyterhub --jupyterHubImage=<jupyterHubImage> The image to use for JupyterHub --jupyterHubAuthenticator=<jupyterHubAuthenticator> The authenticator to use --jupyterNotebookPVCMount=<jupyterNotebookPVCMount> Mount path for PVC. Set empty to disable PVC --reportUsage=<reportUsage> Whether or not to report Kubeflow usage to kubeflow.org --usageId=<usageId> Optional id to use when reporting usage to kubeflow.org Kubeflow 自体(Control plane)の展開 Prototype: kubeflow-core -
Roadmap Index > 0.1 2018-04 0.2 End-of-Quarter 2 1.0 2018
End-of-year Future of Kubeflow -
# Roadmap 2018-04 [Core component] • Argo • ksonnet での起動が可能
• サンプルで用意された argo 用の YAML で Workflow が一応組める程度 • JupyterHub • TFJob – v1alpha1 • Seldon • TFServing • Pachyderm • Ksonnet で起動できるだけ? 0.1 Kubeflow prototype 置き場: hIps://github.com/kubeflow/kubeflow/tree/master/kubeflow Argo の使い方: hIps://github.com/kubeflow/examples/tree/master/mnist • Tensor2tensor (データセット・モデル郡) • Other TFX (Tensorflow Extendet) • tf/model-analysis • tf/transforme • tf/etc -
2018 End-of-Quarter2 (07-09 ݄) [New] • Katlib (Hyper Parameter チューニングシステムの
Vizier クローン by Google) • Horovod integration (分散GPU用 ML Framework with MPI by Uber) • PyTorch operator • Batch interface • Central UI • Easier deployment “click to deploy” [Improvement] TfJob - v1alpha2 Better error reporting for JupyterHub Improved monitoring for serving (Istio integration) 0.2 -
1.0 2018 End-of-Year (KubeCon 2018 NA) • Core Component がプロダクション利用可能に
• 継続的なインテグレーションとモデルのデプロイ 最新のデータを元に自動的に再学習が行われる (定期実行かトリガーが必要な様子) 新しいモデルの精度が良ければ自動的にプロダクションに適用 -
What is KVC (Kubernetes Volume Controller)? Ref: hIps://github.com/IntelAI/experimental-kvc/blob/master/docs/arch.md NFS S3
Aeon (status: Design) • 複数データソース対応 • データの分散配置 • ノード Affinity • 事前のデータ読み込み • Gabage Collec`on • 出力先としての利用 -
Future of Kubeflow Ref: hIps://schd.ws/hosted_files/kccnceu18/d4/Kubeflow_Deep_Dive.pdf Serving Service として公開する 分散学習を行う データサイエンティストがモデルを作る
Katlib 数年後の論文 • 1. kube flow deployment • 2. model • 3. packaging of data -
Cloud Native に近しい技術や CNCF がホストするプロジェクトについて共有し合う会です! 昨今はコンテナ関係のエコシステムが大量に増えてきましたが、 それらの技術検証結果などを発表しあう場として利用していきたいと思っており、仲間を募集しております。 1. Rook の今とこれから
CNCFの15番目のプロジェクトとなったRookは、当初は KubernetesでのCeph as a Service機能にフォーカ スされていますが、目指すところはそこにとどまらず、 様々なストレージサービスを提供するためのフレーム ワークとして設計されています。Rookで今できることの 検証結果と、今後の展望を紹介します。 2. TBD TBD 運営に協力してくださる方 スポンサーしてくださる方も募集中です。