我在Google平台上部署了Pytorch模型,我得到了以下错误:
ERROR: (gcloud.beta.ai-platform.versions.create) Create Version failed. Bad model detected with error: Model requires more memory than allowed. Please try to decrease the model size and re-deploy. If you continue to have error, please contact Cloud ML.配置:
setup.py
from setuptools import setup
REQUIRED_PACKAGES = ['torch']
setup(
name="iris-custom-model",
version="0.1",
scripts=["model.py"],
install_requires=REQUIRED_PACKAGES
)模型版本创建
MODEL_VERSION='v1'
RUNTIME_VERSION='1.15'
MODEL_CLASS='model.PyTorchIrisClassifier'
!gcloud beta ai-platform versions create {MODEL_VERSION} --model={MODEL_NAME} \
--origin=gs://{BUCKET}/{GCS_MODEL_DIR} \
--python-version=3.7 \
--runtime-version={RUNTIME_VERSION} \
--package-uris=gs://{BUCKET}/{GCS_PACKAGE_URI} \
--prediction-class={MODEL_CLASS}发布于 2020-02-26 21:51:19
您需要使用Pytorch编译的软件包,与Cloud平台包信息这里兼容
这个水桶包含与Cloud平台预测兼容的PyTorch编译包。这些文件在stable.html的正式构建中被镜像
从文件
为了在Cloud平台在线预测上部署PyTorch模型,必须将其中一个包添加到您部署的版本的packageURIs字段中。选择与Python和PyTorch版本相匹配的包。包名遵循此模板: 包名=
torch-{TORCH_VERSION_NUMBER}-{PYTHON_VERSION}-linux_x86_64.whl,其中PYTHON_VERSION= cp35-cp35m用于运行时版本< 1.15,cp37-cp37m用于Python 3,运行时版本为>= 1.15。 例如,如果我要部署一个基于PyTorch 1.1.0和Python3的PyTorch模型,我的gcloud命令如下所示: 平台版本创建{VERSION_NAME} -模型{MODEL_NAME} .MODEL_NAME
总结如下:
1)从torch中的install_requires依赖项中删除setup.py
2)在创建版本模型时包含torch包。
!gcloud beta ai-platform versions create {VERSION_NAME} --model {MODEL_NAME} \
--origin=gs://{BUCKET}/{MODEL_DIR}/ \
--python-version=3.7 \
--runtime-version={RUNTIME_VERSION} \
--package-uris=gs://{BUCKET}/{PACKAGES_DIR}/text_classification-0.1.tar.gz,gs://cloud-ai-pytorch/torch-1.3.1+cpu-cp37-cp37m-linux_x86_64.whl \
--prediction-class=model_prediction.CustomModelPredictionhttps://stackoverflow.com/questions/60423140
复制相似问题