Before I asked why GAE can't find TensorFlow lib here https://stackoverflow.com/questions/40241846/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
?
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.To help anyone else, I am posting my hello world tensor flow code for google app engine flexible environment using Python 3 (I know that original question was asked for python 2.7). Also note that webapp2 is not yet compatible with python 3, so I am using Flask.
Complete code is
requirements.txt
app.yaml
main.py
This same code is also posted on github here