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

标签 python tensorflow keras google-cloud-platform google-cloud-functions

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

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

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

首先,我觉得很奇怪 Google 没有提供预装 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))

有没有办法让我在 Cloud Functions 上获取 tensorflow 或 Google 故意阻止安装以让我们使用 ML Engine?

最佳答案

编辑: Tensorflow 1.13.1 now supports Python 3.7.


上一个答案:

目前无法在 Google Cloud Functions 上使用 tensorflow

然而,这并不是因为 Google 故意阻止它: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 引擎。

关于python - 使用 TensorFlow 作为依赖项部署 Google Cloud Functions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52226691/

相关文章:

tensorflow - “NoneType”对象不可下标 - Keras 自定义回调类出错

python - Tensorflow - Deep MNIST 教程 - 将分类器导出到 C++

machine-learning - 我如何将 bool 张量输入到 tf.cond() 而不仅仅是一个 bool 值?

python - 是否可以在 keras 中实现动态类权重?

python - FFmpeg 输出到数组而不保存到文件

python - 如何将 Tensorflow Simple Audio Recognition frozen graph(.pb) 转换为 Core ML 模型?

python - 如何将 TensorFlow (v. 2) Hub 中预训练的 KerasLayer 与 tfrecords 结合起来?

python - 如何在更改 TIME_ZONE 设置时保持 UTC 时间记录?

python - 屏蔽/隐藏 github 访问 token

python - 计算 django python 中 dict 列表中的重复项