google-cloud-platform - 使用自定义预测例程时没有这样的文件或目录:'/tmp/model/0001' google cloud ai platform
问题描述
gcloud 实例上的 /tmp/model 文件夹似乎是空的。即使标准错误日志另有说明,文件似乎也没有从存储帐户正确复制。
请问我该怎么做,我错过了什么。当我提出预测请求时,我能够成功创建模型版本。
这是用于创建模型版本的命令:
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)
解决方案
根据您共享的代码,您似乎没有直接加载模型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
编辑
该问题已在Google 问题跟踪器中报告。响应是,如果要在预测期间使用模型和将要使用的所有工件,则model_dir
需要在执行期间加载from_path
并存储在预测器类中。
推荐阅读
- php - CTF 类型杂耍与成熟 md160 哈希
- vb.net - VB.net 应用程序只能以管理员身份运行
- html - 我如何在表单中向用户建议密码
- oracle - 如何结合使用 Oracle 云基础设施 MYSQL DB 和 XDev API?
- postgresql - ts_rank 什么时候返回值 1
- java - 为什么我的程序在 main 中调用时不接受方法中的 int[] 参数?
- mbaas - 第一次在appwrite mbaas中如何注册?
- angular - 403错误没有被catchError函数Angular 7捕获
- apache-kafka - Kafka:sendOffsetsToTransaction 与多个消费者
- angular - Angular 2中带有类型或模型的简单发布请求