title: unable to utilize tensorflow model under uwsgi + nginx deployment
body: <p>I'm trying to deploy a face detection service using <a href="https://github.com/davidsandberg/facenet/" rel="nofollow noreferrer">MTCNN in tensorflow</a> + flask + uWSGI. I based my deployment on <a href="https://github.com/tiangolo/uwsgi-nginx-flask-docker" rel="nofollow noreferrer">this docker</a> and added this custom <code>uwsgi.ini</code>:</p>
  
  <pre><code>[uwsgi]
  module = main
  callable = app
  enable-threads = true
  cheaper = 2
  processes = 16
  threads = 16
  http-timeout = 60
  </code></pre>
  
  <p>but when I try to do face detection using this docker image I just built, I always get <code>504 Gateway Time-out</code>. Actually when I dug deeper, I noticed that the code runs fine to <a href="https://github.com/davidsandberg/facenet/blob/096ed770f163957c1e56efa7feeb194773920f6e/src/align/detect_face.py#L92" rel="nofollow noreferrer">this session.run line</a>:</p>
  
  <pre><code>    for op_name in data_dict:
          with tf.variable_scope(op_name, reuse=True):
              for param_name, data in iteritems(data_dict[op_name]):
                  try:
                      var = tf.get_variable(param_name)
                      session.run(var.assign(data))
                  except ValueError:
                      if not ignore_missing:
                          raise
  </code></pre>
  
  <p>At first, I thought it was a problem related to threading under uwsgi worker, so I added increased number of processes and threads but without any success.</p>
  
  <p>When I run the same code with flask debugger, it runs just fine and processes the image in less than a second. So it is not a problem with code but a problem with config or combination of these tools.</p>