How does tensorflow ignore undefined flags

泄露秘密 提交于 2019-12-01 17:15:52

I solved my problem by defining these flags in tensorflow model: my_tf_model.py.

tf.app.flags.DEFINE_string('bind', '', 'Server address')
tf.app.flags.DEFINE_integer('timeout', 30, 'Server timeout')

And then changed my gunicorn command line to use double dash style command line:

gunicorn --bind 0.0.0.0:5000 --timeout 30 wsgi:app

But I think there should be some other way rather than this hack to resolve the globally-used flags.

jlshix

I solved this problem by using gunicorn default config file: gunicorn.conf.py

You can create a config file named gunicorn.conf.py:

bind = 0.0.0.0:5000
timeout = 30

FYI: Settings - Gunicorn documentation

gunicorn_conf.py is the default config file name defined in function gunicorn.config.get_default_config_file, so now you can start your service by command gunicorn wsgi:app.

Now tensorflow knows nothing about gunicorn config.

Notice: this default config name is not mentioned in gunicorn documentation, it's not sure whether this config file name remains unchanged in future version.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!