Keras predict not returning inside celery task

前端 未结 2 660
有刺的猬
有刺的猬 2021-02-09 08:17

Following Keras function (predict) works when called synchronously

pred = model.predict(x)

But it does not work when called from within an asy

2条回答
  •  闹比i
    闹比i (楼主)
    2021-02-09 08:35

    I got the reference from this Blog

    • Tensorflow is Thread-Specific data structure that are working behind the scenes when you call model.predict
    GRAPH = tf.get_default_graph()
    with GRAPH.as_default():
        pred = model.predict
    return pred
    

    But Celery uses processes to manage all its worker pools. So at this point, things are still not working on Celery for that you need to use gevent or eventlet library

    pip install gevent

    now run celery as :

    celery -A mysite worker --pool gevent -l info

提交回复
热议问题