alexdivet
alexdivet

Reputation: 33

Deploying Google Cloud Functions with TensorFlow as a dependency

I'd like to use Google Cloud Functions to deploy a keras model saved in JSON (including weights in HDF5) with tensorflow as backend.

The deployment succeed when I don't specify tensorflow in requirements.txt. Although when testing the function in GCP, I get the error message specifying that tensorflow could not be found.

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

First, I find it quite strange that Google doesn't provide environments with tensorflow pre-installed.

But now if I specify tensorflow in requirements.txt, deployment fails with the error message

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))

Is there a way I can get tensorflow on Cloud Functions or Google deliberately blocks the install to get us to use ML Engine?

Upvotes: 3

Views: 1649

Answers (1)

Dustin Ingram
Dustin Ingram

Reputation: 21520

EDIT: Tensorflow 1.13.1 now supports Python 3.7.


Previous answer:

There isn't currently a way to use tensorflow on Google Cloud Functions.

However, it's not because Google is deliberately blocking it: the tensorflow package only provides built distributions for CPython 2.7, 3.3, 3.4, 3.5 and 3.6, but the Cloud Functions Python runtime is based on Python version 3.7.0, so pip (correctly) can't find any compatible distributions.

There are currently some compatibility issues with TensorFlow and Python 3.7, but once that is fixed, tensorflow should be installable on Google Cloud Functions. For now though, you'll have to use ML Engine.

Upvotes: 5

Related Questions