我有一个简单的应用程序,它有PyTorch模型来预测文本中的情绪。当模型开始工作时,它会在容器中下载。不幸的是,每次在顶点ai中的部署都失败,消息如下:
Failed to deploy model "emotion_recognition" to endpoint "emotions" due to the error: Error: model server never became ready. Please validate that your model file or container configuration are valid.

这是我的Dockerfile:
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.8-slim
COPY requirements.txt ./requirements.txt
RUN pip install -r requirements.txt
WORKDIR /usr/src/emotions
COPY ./schemas/ /emotions/schemas
COPY ./main.py /emotions
COPY ./utils.py /emotions
ENV PORT 8080
ENV HOST "0.0.0.0"
WORKDIR /emotions
EXPOSE 8080
CMD ["uvicorn", "main:app"]这是我的main.py:
from fastapi import FastAPI,Request
from utils import get_emotion
from schemas.schema import Prediction, Predictions, Response
app = FastAPI(title="People Analytics")
@app.get("/isalive")
async def health():
message="The Endpoint is running successfully"
status="Ok"
code = 200
response = Response(message=message,status=status,code=code)
return response
@app.post("/predict",
response_model=Predictions,
response_model_exclude_unset=True)
async def predict_emotions(request: Request):
body = await request.json()
print(body)
instances = body["instances"]
print(instances)
print(type(instances))
instances = [x['text'] for x in instances]
print(instances)
outputs = []
for text in instances:
emotion = get_emotion(text)
outputs.append(Prediction(emotion=emotion))
return Predictions(predictions=outputs)我看不到云日志记录错误的原因,所以我很好奇原因。请检查我的健康/预测路线是否对顶点ai是正确的,或有其他东西我必须改变。
发布于 2022-12-02 13:08:01
我建议在部署端点时,应该使用启用日志,以便从日志中获得更有意义的信息。
这个问题可能是由于不同的原因:
如果上述任何建议有效,则需要通过为修好它创建一个支持案例来联系GCP支持。如果不使用内部GCP资源,社区就不可能排除它
https://stackoverflow.com/questions/74637402
复制相似问题