根据GCP AI平台的文档here,自定义预测例程部署应允许包含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)"
当指定类似soREQUIRED_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)"
这里会出什么问题
原来最初的错误
Bad model detected with error: "Failed to load model: Unexpected error when loading the model: 'str' object has no attribute 'decode' (Error code: 0)"
实际上是由模型格式问题引起的。这似乎是TensorFlow Keras的a known issue(尽管我的TF版本是1.15,引用的TF版本是2.1.0)。一旦我使用了TensorFlow SavedModel format,错误立即消失了,我还能够将jsonchema依赖项按原样包含在setup.py
文件中相关问题 更多 >
编程相关推荐