问题描述
在我问为什么GAE在这里找不到TensorFlow库之前 https://stackoverflow.com/questions/40241846/why-googleappengine-gives-me-importerror-no-module-named-tensorflow
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
Dmytro Sadovnychyi
告诉我,GAE无法运行TensorFlow,但GAE flexible可以运行.
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)
以Yaml格式显示vm: true
.
这是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"
部署成功,但是在appspot
访问我的应用程序时,我收到服务器内部错误消息,控制台仍然显示ImportError: No module named tensorflow
.
Deploy successes, but I getting Server Internal Error when visiting my app at appspot
and console still shows me ImportError: No module named tensorflow
.
要使基于TensorFlow的应用程序在flexible enviroment
中运行,我需要做些什么?
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.
创建一个requirements.txt
文件,并列出您的依赖项,包括那里的Tensor Flow.
Create a requirements.txt
file and list your dependencies, including Tensor Flow there.
这篇关于如何在Google App Engine灵活环境中运行TensorFlow?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!