You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vertex AI部署YOLO自定义Docker容器模型失败求助

Vertex AI部署YOLO自定义Docker容器模型失败求助

我正在尝试把自定义YOLO模型打包成容器部署到Vertex AI,已经顺利完成了以下操作:

  • 本地构建并测试了Docker镜像
  • 验证了容器里的FastAPI+YOLO API运行正常
  • 把同一个镜像部署到Cloud Run并测试通过

但部署到Vertex AI作为自定义容器模型时遇到了问题。

环境配置细节

  • 基础镜像:pytorch/pytorch:2.2.0-cuda12.1-cudnn8-runtime(用于GPU支持)
  • 服务框架:FastAPI + Uvicorn + Gunicorn
  • 硬件目标:尝试使用带NVIDIA P4 GPU的n1-standard-4实例
  • Docker CMD:容器运行startup.sh脚本,加载模型并启动FastAPI服务器
  • 推理请求格式:期望JSON里包含base64编码的图片

部署步骤

  1. 本地构建Docker镜像并通过docker run测试
  2. 把镜像推送到Google Artifact Registry
  3. 通过以下脚本创建Vertex AI模型:
- name: Upload Mobile Model
        run: |
          EXISTING_MODEL=$(gcloud ai models list --region=$REGION --filter="displayName=freshpet-mobile" --format="value(name)" --limit=1)
          if [ -z "$EXISTING_MODEL" ]; then
            gcloud ai models upload --region=$REGION --display-name=freshpet-mobile --container-image-uri=$IMAGE_NAME_MOBILE
          else
            echo "Mobile model already exists, skipping upload."
          fi

      - name: Wait for Mobile Model to be Registered
        run: |
            timeout=$TIMEOUT_SECONDS
            start_time=$(date +%s)
            while true; do
              MODEL_MOBILE_NAME=$(gcloud ai models list --region=$REGION --filter="displayName=freshpet-mobile" --format="value(name)" --limit=1)
              if [ -n "$MODEL_MOBILE_NAME" ]; then
                echo "Model Registered: $MODEL_MOBILE_NAME"
                echo "MODEL_MOBILE_NAME=$MODEL_MOBILE_NAME" >> $GITHUB_ENV
                break
              fi
              if [ $(( $(date +%s) - start_time )) -gt $timeout ]; then
                echo "Timeout waiting for model registration." && exit 1
              fi
              sleep 10
            done
  1. 创建Endpoint并部署模型:
- name: Deploy Mobile Model to Endpoint
        run: |
          ENDPOINT_MOBILE_ID=$(gcloud ai endpoints list --region=$REGION --filter="displayName=freshpet-mobile-endpoint" --format="value(name)" --limit=1)
          if [ -z "$ENDPOINT_MOBILE_ID" ]; then
            ENDPOINT_MOBILE_ID=$(gcloud ai endpoints create --region=$REGION --display-name=freshpet-mobile-endpoint --format="value(name)")
          fi
          gcloud ai endpoints deploy-model $ENDPOINT_MOBILE_ID \
            --region=$REGION \
            --model=$MODEL_MOBILE_NAME \
            --display-name=mobile-container-deploy \
            --machine-type=$MACHINE_TYPE \
            --accelerator=count=1,type=$GPU_TYPE \
            --min-replica-count=$MIN_REPLICAS \
            --enable-access-logging \
            --autoscaling-metric-specs=$AUTOSCALING_METRIC​

遇到的问题

  • 模型在Vertex AI上加载失败,但在Cloud Run上完全正常运行
  • Vertex AI端点里没有生成任何日志,导致调试工作难以推进

注:该容器在Cloud Run可正常运行,但在Vertex AI部署失败(原本配有相关截图)

备注:内容来源于stack exchange,提问作者Abhishek Kumar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.13 19:18:04