顶点管道:CustomPythonPackageTrainingJobRunOp 不提供 WorkerPoolSpecs
Posted
技术标签:
【中文标题】顶点管道:CustomPythonPackageTrainingJobRunOp 不提供 WorkerPoolSpecs【英文标题】:Vertex Pipeline: CustomPythonPackageTrainingJobRunOp not supplying WorkerPoolSpecs 【发布时间】:2021-09-05 14:21:42 【问题描述】:我正在尝试使用 Vertex AI 上的 Kubeflow 管道运行自定义包训练管道。我将训练代码打包在 Google Cloud Storage 中,我的管道是:
import kfp
from kfp.v2 import compiler
from kfp.v2.dsl import component
from kfp.v2.google import experimental
from google.cloud import aiplatform
from google_cloud_pipeline_components import aiplatform as gcc_aip
@kfp.dsl.pipeline(name=pipeline_name, pipeline_root=pipeline_root_path)
def pipeline():
training_job_run_op = gcc_aip.CustomPythonPackageTrainingJobRunOp(
project=project_id,
display_name=training_job_name,
model_display_name=model_display_name,
python_package_gcs_uri=python_package_gcs_uri,
python_module=python_module,
container_uri=container_uri,
staging_bucket=staging_bucket,
model_serving_container_image_uri=model_serving_container_image_uri)
# Upload model
model_upload_op = gcc_aip.ModelUploadOp(
project=project_id,
display_name=model_display_name,
artifact_uri=output_dir,
serving_container_image_uri=model_serving_container_image_uri,
)
model_upload_op.after(training_job_run_op)
# Deploy model
model_deploy_op = gcc_aip.ModelDeployOp(
project=project_id,
model=model_upload_op.outputs["model"],
endpoint=aiplatform.Endpoint(
endpoint_name='0000000000').resource_name,
deployed_model_display_name=model_display_name,
machine_type="n1-standard-2",
traffic_percentage=100)
compiler.Compiler().compile(pipeline_func=pipeline,
package_path=pipeline_spec_path)
当我尝试在 Vertex AI 上运行此管道时,我收到以下错误:
"insertId": "qd9wxrfnoviyr",
"jsonPayload":
"levelname": "ERROR",
"message": "google.api_core.exceptions.InvalidArgument: 400 List of found errors:\t1.Field: job_spec.worker_pool_specs; Message: At least one worker pool should be specified.\t\n"
【问题讨论】:
您是否在训练代码中的某处定义了worker_pool_specs? @RiccoD 我没有。我通过在CustomPythonPackageTrainingJobRunOp
中指定将转移到管道运行的相关信息来计算。
如果我错了,请纠正我。您是否属于CustomPythonPackageTrainingJobRunOp
类的run()
并定义了replica_count = 1
?
@RiccoD 我没有在CustomPythonPackageTrainingJobRunOp
中定义replica_count
和machine_type
。一旦我添加了这些参数,管道就成功了,谢谢!
【参考方案1】:
我原来的CustomPythonPackageTrainingJobRunOp
没有定义worker_pool_spec
,这是错误的原因。在我指定replica_count
和machine_type
后,错误解决了。最终的训练操作是:
training_job_run_op = gcc_aip.CustomPythonPackageTrainingJobRunOp(
project=project_id,
display_name=training_job_name,
model_display_name=model_display_name,
python_package_gcs_uri=python_package_gcs_uri,
python_module=python_module,
container_uri=container_uri,
staging_bucket=staging_bucket,
base_output_dir=output_dir,
model_serving_container_image_uri=model_serving_container_image_uri,
replica_count=1,
machine_type="n1-standard-4")
【讨论】:
你是在一个独立的笔记本里面,最好是 Colab 笔记本?官方文档没有很好的解释CustomPythonPackageTrainingJobRunOp
的不同参数。
@S.P 不,这是一个生产管道,因此在笔记本中运行它是不可行的。不管问题解决了。以上是关于顶点管道:CustomPythonPackageTrainingJobRunOp 不提供 WorkerPoolSpecs的主要内容,如果未能解决你的问题,请参考以下文章