-
Notifications
You must be signed in to change notification settings - Fork 607
AttributeError _thread._local error on inference when using Keras + Tensorflow #831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for bringing this to our attention! We will be switching from Flask to FastAPI soon (hopefully merging into master in the next few days, and releasing shortly thereafter). Let’s see what happens when that gets in, hopefully the issue will just go away |
@RobertLucian I wonder if this has been resolved now that 0.14 is released, is it easy for you to check this? |
@deliahu yeah, I'm adding this to my list of things to do. I will be back with an answer. |
@deliahu just tried this on |
@RobertLucian thank you for checking. Should we close this issue since |
@RobertLucian sounds good, thank you! |
Hi @RobertLucian Thank you so much!! |
Version
On version
0.13.x
.Description
When using the latest version of Keras (
2.3.1
) and Tensorflow as its backend (2.x
), theAttributeError: '_thread._local' object has no attribute 'value'
error is encountered because_SYMBOLIC_SCOPE.value
does not exist within the Tensorflow backend. The error is encountered when making the prediction and not when the model is loaded.It must be noted that this specifically happens if the
keras.models.load_model
function is used.It appears to be due to a conflict between keras/tensorflow and flask (the underlying web framework used in cortex). More on that here:
keras-team/keras#13353
Alternatives
Alt. 1
One very good way of circumventing this is to replace the
with
Alt. 2
Another possible way to circumvent this is to switch to theano backend by adding
KERAS_BACKEND=theano
environment variable inside thecortex.yaml
configuration file. But this only works for the CPU inferencing. With this backend, to make it work on the GPU too,pygpu
has to be installed and this dependecy can only be installed withconda
or by building it from source, which is anyway riddled with bugs. Don't forget thetheano
project is no longer maintained, which means it's only a temporary fix.Steps to reproduce
2.3.x
) with tensorflow (2.x
) using thekeras.models.load_model
function.cortex logs <api name>
.Stack traces
(error output from
cortex logs <api name>
)The text was updated successfully, but these errors were encountered: