Kosmos Kosmos - 9 months ago 143
Python Question

How to run TensorFlow in Google App Engine Flexible Enviroment?

Before I asked why GAE can't find TensorFlow lib here Why GoogleAppEngine gives me ImportError: No module named tensorflow?


Dmytro Sadovnychyi
told me that GAE can't run TensorFlow, but GAE flexible can.

So I created my project in USA zone and trying to deploy my simple project:

import webapp2
import tensorflow as tf

class MainHandler(webapp2.RequestHandler):
def get(self):
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
a = tf.constant(10)
b = tf.constant(32)
self.response.write(sess.run(a + b))

app = webapp2.WSGIApplication([
('/', MainHandler)
], debug=True)

vm: true
in yaml.

This is yaml:

application: tstmchnlrn
version: 1
runtime: python27
vm: true
api_version: 1
threadsafe: yes

- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico

- url: .*
script: main.app

- name: webapp2
version: "2.5.2"

Deploy successes, but I getting Server Internal Error when visiting my app at
and console still shows me
ImportError: No module named tensorflow

What I need to do to make TensorFlow based app to run in
flexible enviroment

Answer Source

This sounds like the dependency didn't get pushed to the instance.

Create a requirements.txt file and list your dependencies, including Tensor Flow there.