【问题标题】:Vertex AI: Batch prediction for custom model fails with RuntimeError: BatchPredictionJob resource has not been createdVertex AI:自定义模型的批量预测因运行时错误而失败:尚未创建 BatchPredictionJob 资源
【发布时间】:2023-02-06 17:24:03
【问题描述】:

我们正在尝试为自定义模型运行批量预测。

培训是在本教程之后完成的: https://codelabs.developers.google.com/codelabs/vertex-ai-custom-code-training#4

在管道中提交作业的代码:

model = aiplatform.Model(model_path)
batch_prediction_job = model.batch_predict(
    gcs_source=gcs_source,
    gcs_destination_prefix=gcs_destination,
    machine_type='n1-standard-4',
    instances_format='csv',
    sync=False
)

运行批量预测作业失败,管道中出现以下错误:

JobState.JOB_STATE_FAILED
[KFP Executor 2023-01-18 14:08:09,862 INFO]: BatchPredictionJob projects/472254905662/locations/us-central1/batchPredictionJobs/3522181183414730752 current state:
JobState.JOB_STATE_FAILED
Traceback (most recent call last):
File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.7/site-packages/kfp/v2/components/executor_main.py", line 104, in <module>
executor_main()
File "/usr/local/lib/python3.7/site-packages/kfp/v2/components/executor_main.py", line 100, in executor_main
executor.execute()
File "/usr/local/lib/python3.7/site-packages/kfp/v2/components/executor.py", line 309, in execute
result = self._func(**func_kwargs)
File "/tmp/tmp.ZqplJAZqqL/ephemeral_component.py", line 23, in create_batch_inference_component
print(f'Batch prediction job "{batch_prediction_job.resource_name}" submitted')
File "/usr/local/lib/python3.7/site-packages/google/cloud/aiplatform/base.py", line 676, in resource_name
self._assert_gca_resource_is_available()
File "/usr/local/lib/python3.7/site-packages/google/cloud/aiplatform/base.py", line 1324, in _assert_gca_resource_is_available
else ""
RuntimeError: BatchPredictionJob resource has not been created.

失败的批量预测作业中存在错误,但无法理解其含义:

Batch prediction job BatchPredictionJob 2023-01-18 14:21:50.490123 encountered the following errors:

Model server terminated: model server container terminated: exit_code: 1 reason: "Error" started_at { seconds: 1674052639 } finished_at { seconds: 1674052640 }

为相同的泰坦尼克号数据集训练的 AutoML 模型的批量预测有效。

没有办法解决这个问题。我们尝试了不同的instance_format,而不是指定machine_type,改进了预测数据集(指南说所有字符串字段都应该用双引号括起来)但这并没有停止。

【问题讨论】:

  • 嗨@havryliuk,你能提供你试过的示例数据和示例代码吗?
  • 您好@ShipraSarkar,您是指包含数据准备和模型训练的整个代码吗?我已经分享了我们提交自定义模型批量预测的代码。
  • 嗨@havryliuk,你能用不同的数据集重试吗?
  • @ShipraSarkar,我们尝试使用正确格式的 json(实例 json)而不是 csv,因为这是一个 scikit-learn 模型,但错误是相同的:RuntimeError: BatchPredictionJob resource has not been created.
  • 嗨@havryliuk,看来这个问题需要进一步调查,所以如果你有支持计划,请创建一个新的GCP support case。否则,您可以在Issue Tracker 上开一个新问题。

标签: google-cloud-vertex-ai


【解决方案1】:

我们已经设法与我们的团队解决了这个问题的三个问题:

  1. 我们使用不同的容器来训练和提供模型。我们没有控制容器中的 scikit-learn 版本,而是为模型服务设置了它的版本。我们刚刚在用于训练的容器中安装了所需的 scikit 版本。
  2. 我们不知道批量预测输入的正确格式。虽然文档中有使用端点进行在线推理的样本和示例,但没有用于批量预测的输入文件样本。此答案中描述了格式:https://stackoverflow.com/a/68123138/2082681。您只需要将示例行作为数组传递,并且(非常重要)拥有扩展名为 .jsonl 的源文件。
  3. 最后(!),即使在我们的批量预测开始工作并生成具有正确预测的文件之后,提交批量预测的管道仍然失败(!)并出现相同的错误:BatchPredictionJob resource has not been created. 这终于结束了通过删除传递给model.batch_predict 的sync=False 修复。

    我们的团队(3 人)花了大约三周的时间才弄明白。现在,管道是绿色的,批量预测正在运行。

【讨论】:

    猜你喜欢
    • 2021-12-23
    • 2021-12-24
    • 1970-01-01
    • 2021-11-19
    • 2022-01-01
    • 2021-12-09
    • 2021-12-28
    • 2021-12-26
    • 2021-10-29
    相关资源
    最近更新 更多