MLflow
MLflow: the open-source platform for the machine leaning lifecycle, 管理machine learning整个生命周期的一款开源产品,主要提供了三种服务:
- MLflow Tracking: 记录并维护了machine learning的代码,数据,matrics,config,results…并结合UI展示
- MLflow Projects: 将machine learning的model带包成一个docker image,实现run anywhere
- MLflow Models: 标准化machine learning的model及其configuration files,实现与其他平台共同开发/部署
几乎支持市面上的所有Machine Learning frameworks, TensorFlow/PyTorch/Spark/SKlearn/R…
开源,并有着Databricks/Microsoft等一众公司的committer.
Seldon
Seldon: the open-source platform to help deploy machine learning models, 主要focus在model的deployment
- 可以deploy市面上几乎所有的machine learning model
- 不仅可以deploy在both in cloud and on-promise
- expose metrics/HTTP trance等monitoring信息
Example: Train ML model using MLflow, Deploy using Seldon
Train Model with MLflow
1 | import os |
在对应的Model Storage下,可以看到MLmodel
文件这个文件内包含了很多信息:模型本身model.pkl
,模型产生的env conda.yaml
… 之后Seldon
会读取这部分信息去做deploy
1 | artifact_path: model |
Deploy ML model with Seldon
Prerequisites:
- a k8s cluster
- helm installed
1
2
3
4
5
6
7
8curl https://raw.githubusercontent.com/helm/helm/master/scripts/get > get_helm.sh
chmod 777 get_helm.sh
./get_helm.sh
helm init #install Tiller, a deployment/service/pod of Tiller will be installed automatically in **kube-system** NS
#### create account for Tiller
kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'
install Seldon
1 | helm install \ |
install Ambassador (k8s cloud native gateway)
1 | helm install stable/ambassador --name ambassador --set crds.keep=false |
Port forwarding:
1 | #### run below command in another terminal |
install Seldon Analytics
1 | # install Seldon Analytics with prometheus and grafana |
1 | #### run below command in another terminal |
Deploy Model
1 | apiVersion: machinelearning.seldon.io/v1alpha2 |