根据此处的 GCP AI Platform 文档,自定义预测例程部署应允许包含 PyPI 依赖项。我在setup.py
脚本中包含了我对 jsonschema 的依赖,如下所示:
from setuptools import setup
from setuptools import find_packages
REQUIRED_PACKAGES = ['jsonschema']
setup(
name='custom_code',
version='1.0.2',
scripts=['predictor.py', 'preprocess.py'],
install_requires=REQUIRED_PACKAGES,
packages=find_packages(),
include_package_data=True
)
但在部署时收到此错误消息:
ERROR: (gcloud.beta.ai-platform.versions.create) Create Version failed. Bad model detected with error: "Failed to load model: Unexpected error when loading the model: 'str' object has no attribute 'decode' (Error code: 0)"
指定这样的版本时,同样的错误仍然存在REQUIRED_PACKAGES = ['jsonschema==3.2.0']
。然后我使用了一个较低的版本:
from setuptools import setup
from setuptools import find_packages
REQUIRED_PACKAGES = ['jsonschema==3.0.0']
setup(
name='custom_code',
version='1.0.2',
scripts=['predictor.py', 'preprocess.py'],
install_requires=REQUIRED_PACKAGES,
packages=find_packages(),
include_package_data=True
)
但现在出现此错误:
ERROR: (gcloud.beta.ai-platform.versions.create) Create Version failed. Bad model detected with error: "Failed to load model: Unexpected error when loading the model: problem in predictor - DistributionNotFound: The 'jsonschema' distribution was not found and is required by the application (Error code: 0)"
这里有什么问题?