【问题标题】:Deploying Google Cloud Functions with TensorFlow as a dependency使用 TensorFlow 作为依赖项部署 Google Cloud Functions
【发布时间】:2019-02-13 01:15:32
【问题描述】:

我想使用 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?

【问题讨论】:

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


【解决方案1】:

编辑: 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 Engine。

【讨论】:

  • 非常感谢您提供此信息,这是其他任何地方都没有的信息!现在这终于解释了为什么 Google Cloud Function 无法使用 TensorFlow 后端导入 Keras...
猜你喜欢
  • 1970-01-01
  • 2019-04-07
  • 2019-12-17
  • 1970-01-01
  • 1970-01-01
  • 2019-10-06
  • 2020-11-03
  • 2021-10-25
  • 2020-05-31
相关资源
最近更新 更多