gcloud实例上的/tmp/model文件夹似乎是空的。看起来这些文件没有从存储帐户正确复制过来,尽管stderr日志显示并非如此。
请告诉我我该怎么做,我遗漏了什么。当我提出预测请求时,我能够成功地创建模型版本。

以下是用于创建模型版本的命令:
gcloud beta ai-platform versions create $VERSION_NAME --model $MODEL_NAME --runtime-version 1.15 --python-version 3.7 --origin gs://$BUCKET_NAME/custom_prediction_routine/model/ --package-uris gs://$BUCKET_NAME/custom_prediction_routine/custom_predict_code-0.1.tar.gz --prediction-class predictor.MyPredictor这是from_path类方法:
@classmethod
def from_path(cls, model_dir):
sys.stderr.write(str(model_dir))
return cls(model_dir)发布于 2020-08-25 03:56:41
根据您共享的代码,您似乎没有直接在from_path中加载模型,而是直接将路径发送到您的Predictor实例。
尝试直接在from_path中加载模型,例如,使用keras模型:
@classmethod
def from_path(cls, model_dir):
model = keras.models.load_model(model_dir) # Load with Keras, or the appropriate format
return cls(model)如果问题仍然存在,请尝试从from_path函数内部发出预热预测请求。例如:
@classmethod
def from_path(cls, model_dir):
model = keras.models.load_model(model_dir)
predictor = cls(model)
outputs = predictor.predict([[1,2,3,4,5]]) # Here goes your warm up prediction request
return predictor编辑
谷歌问题跟踪器上的here报告了这个问题。响应是,如果要在预测期间使用模型和所有将从model_dir使用的工件,则需要在from_path的执行期间加载它们,并将其存储在predictor类中。
https://stackoverflow.com/questions/63539189
复制相似问题