Kosmos Kosmos - 1 month ago 29
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?

And

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()
self.response.write(sess.run(hello))
a = tf.constant(10)
b = tf.constant(32)
self.response.write(sess.run(a + b))
#self.response.write('asd');


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


witn
vm: true
in yaml.

This is yaml:

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

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

- url: .*
script: main.app

libraries:
- name: webapp2
version: "2.5.2"


Deploy successes, but I getting Server Internal Error when visiting my app at
appspot
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

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.

Comments