3

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?

1

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

1 Comment

thank you so much for this info which was nowhere else available! Now this finally explains why Google Cloud Function cannot import Keras with TensorFlow backend...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.