
2.2.1 训练和监测进展
下一步是使用Kubeflow Pipeline来训练模型。我们将使用一个预先创建的训练容器[1]来下载训练数据并训练模型。见例2-10,我们在train_pipeline.py中预建了一个工作流,在本书GitHub示例仓库(https://oreil.ly/Kubeflow_for_ML)的ch2文件夹中训练一个RandomForestClassifier。
例2-10:创建训练工作流示例

如果遇到问题,你可以查看Kubeflow故障排除指南(https://oreil.ly/nvNnC)。
如图2-1所示,Kubeflow用户界面有几种不同的访问方式。在本地部署一个端口转发是最简单的方法:只需运行kubectl port-forward svc/istio-ingressgateway -n istio-system 7777:80,然后访问localhost:7777即可。如果你已经在GCP上进行了部署,可以访问https://<deploy ment_name>.endpoints.<project_name>.cloud.google。否则,你可以通过运行kubectl get ingress -n istio-system来获取网关服务的地址。

图2-1:Kubeflow Web用户界面
单击“Pipelines”,或者在根URL中添加_/pipeline/,我们就能看到Pipelines的Web用户界面,如图2-2所示。

图2-2:Pipeline Web用户界面
从这里我们可以上传Pipeline,之后就可以使用相同的Web用户界面来创建Pipeline的运行。单击上传的Pipeline,你就可以创建一个运行,如图2-3所示。

图2-3:Pipeline详情页
[1] 容器来自这个GitHub仓库(https://oreil.ly/f-bO3)。