使用TensorFlow作为依赖项部署Google Cloud Functions

问题描述 投票:3回答:1

我想使用Google Cloud Functions来部署以JSON格式保存的keras模型(包括HDF5中的权重),并将tensorflow作为后端。

当我没有在requirements.txt中指定tensorflow时,部署成功。虽然在GCP中测试函数时,我收到错误消息,指出无法找到tensorflow。

Error: function crashed. Details:
No module named 'tensorflow'

首先,我发现谷歌没有提供预先安装张量流的环境,这很奇怪。

但是现在,如果我在requirements.txt中指定了tensorflow,则部署将失败并显示错误消息

ERROR: (gcloud.beta.functions.deploy) OperationError: 
code=3, message=Build failed: USER ERROR:
`pip_download_wheels` had stderr output:
 Could not find a version that satisfies the 
requirement tensorflow (from -r /dev/stdin (line 5)) 
(from versions: )
No matching distribution found for tensorflow (from -r 
/dev/stdin (line 5))

有没有办法让我可以在云功能上获得张量流,或谷歌故意阻止安装让我们使用ML引擎?

python tensorflow deployment keras google-cloud-functions
1个回答
5
投票

编辑:Tensorflow 1.13.1 now supports Python 3.7.


上一个答案:

目前没有办法在Google Cloud Functions上使用tensorflow

然而,这不是因为谷歌故意阻止它:tensorflow package只提供CPython 2.7,3.3,3.4,3.5和3.6的内置发行版,但the Cloud Functions Python runtime is based on Python version 3.7.0,所以pip(正确)找不到任何兼容的发行版。

目前有some compatibility issues with TensorFlow and Python 3.7,但一旦修复,tensorflow应该可以安装在Google Cloud Functions上。但就目前而言,你必须使用ML引擎。

© www.soinside.com 2019 - 2024. All rights reserved.