Trouble with the predict function of my model while in a separate thread
I have a saved model that I can generate a prediction when I run it on the main thread. When I try to use the same function in a thread I get the following error.
Note a summary of my code will be pasted after the error.
Exception in thread Thread-6:
Traceback (most recent call last):
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libthreading.py", line 916, in _bootstrap_inner
self.run()
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libthreading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "D:PiChessCoreComModule.py", line 49, in threader
b = Globals.moduleManager.GetPrediction(predictionSet)
File "D:PiChessCoreManagementModel.py", line 56, in GetPrediction
return self.Model.predict(data, steps=10)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonkerasenginetraining.py", line 1878, in predict
self, x, batch_size=batch_size, verbose=verbose, steps=steps)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonkerasenginetraining_arrays.py", line 295, in predict_loop
batch_outs = f(ins)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonkerasbackend.py", line 2983, in __call__
self._make_callable(feed_arrays, feed_symbols, symbol_vals, session)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonkerasbackend.py", line 2928, in _make_callable
callable_fn = session._make_callable_from_options(callable_opts)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonclientsession.py", line 1471, in _make_callable_from_options
return BaseSession._Callable(self, callable_options)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonclientsession.py", line 1425, in __init__
session._session, options_ptr, status)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonframeworkerrors_impl.py", line 528, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Requested tensor connection from unknown node: "dense_input:0".
Exception ignored in: <bound method BaseSession._Callable.__del__ of <tensorflow.python.client.session.BaseSession._Callable object at 0x000001E7749C5438>>
Traceback (most recent call last):
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonclientsession.py", line 1455, in __del__
self._session._session, self._handle, status)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonframeworkerrors_impl.py", line 528, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: No such callable handle: 2093487919952
The model is loaded into memory when I start running the code. To do this I created a globals object that loads the model the following way.
self.ModelName = ModelName
self.Model = load_model("Models/" + self.ModelName + '.mdl')
self.Model._make_predict_function()
To use the predict function it is run in a thread
predict = self.Model.predict(data, steps=10)
I know the data supplied is correct for I get a result if I just cut out the threading aspect out of my code and make my code into a single thread.
I cut out most of code since its split up into multiple files and as I tried to paste here stack overflow told me I had to much code.
If needed please let me know which sections of code would be most beneficial to post in as an edit.
python multithreading tensorflow
add a comment |
I have a saved model that I can generate a prediction when I run it on the main thread. When I try to use the same function in a thread I get the following error.
Note a summary of my code will be pasted after the error.
Exception in thread Thread-6:
Traceback (most recent call last):
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libthreading.py", line 916, in _bootstrap_inner
self.run()
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libthreading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "D:PiChessCoreComModule.py", line 49, in threader
b = Globals.moduleManager.GetPrediction(predictionSet)
File "D:PiChessCoreManagementModel.py", line 56, in GetPrediction
return self.Model.predict(data, steps=10)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonkerasenginetraining.py", line 1878, in predict
self, x, batch_size=batch_size, verbose=verbose, steps=steps)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonkerasenginetraining_arrays.py", line 295, in predict_loop
batch_outs = f(ins)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonkerasbackend.py", line 2983, in __call__
self._make_callable(feed_arrays, feed_symbols, symbol_vals, session)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonkerasbackend.py", line 2928, in _make_callable
callable_fn = session._make_callable_from_options(callable_opts)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonclientsession.py", line 1471, in _make_callable_from_options
return BaseSession._Callable(self, callable_options)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonclientsession.py", line 1425, in __init__
session._session, options_ptr, status)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonframeworkerrors_impl.py", line 528, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Requested tensor connection from unknown node: "dense_input:0".
Exception ignored in: <bound method BaseSession._Callable.__del__ of <tensorflow.python.client.session.BaseSession._Callable object at 0x000001E7749C5438>>
Traceback (most recent call last):
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonclientsession.py", line 1455, in __del__
self._session._session, self._handle, status)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonframeworkerrors_impl.py", line 528, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: No such callable handle: 2093487919952
The model is loaded into memory when I start running the code. To do this I created a globals object that loads the model the following way.
self.ModelName = ModelName
self.Model = load_model("Models/" + self.ModelName + '.mdl')
self.Model._make_predict_function()
To use the predict function it is run in a thread
predict = self.Model.predict(data, steps=10)
I know the data supplied is correct for I get a result if I just cut out the threading aspect out of my code and make my code into a single thread.
I cut out most of code since its split up into multiple files and as I tried to paste here stack overflow told me I had to much code.
If needed please let me know which sections of code would be most beneficial to post in as an edit.
python multithreading tensorflow
add a comment |
I have a saved model that I can generate a prediction when I run it on the main thread. When I try to use the same function in a thread I get the following error.
Note a summary of my code will be pasted after the error.
Exception in thread Thread-6:
Traceback (most recent call last):
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libthreading.py", line 916, in _bootstrap_inner
self.run()
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libthreading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "D:PiChessCoreComModule.py", line 49, in threader
b = Globals.moduleManager.GetPrediction(predictionSet)
File "D:PiChessCoreManagementModel.py", line 56, in GetPrediction
return self.Model.predict(data, steps=10)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonkerasenginetraining.py", line 1878, in predict
self, x, batch_size=batch_size, verbose=verbose, steps=steps)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonkerasenginetraining_arrays.py", line 295, in predict_loop
batch_outs = f(ins)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonkerasbackend.py", line 2983, in __call__
self._make_callable(feed_arrays, feed_symbols, symbol_vals, session)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonkerasbackend.py", line 2928, in _make_callable
callable_fn = session._make_callable_from_options(callable_opts)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonclientsession.py", line 1471, in _make_callable_from_options
return BaseSession._Callable(self, callable_options)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonclientsession.py", line 1425, in __init__
session._session, options_ptr, status)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonframeworkerrors_impl.py", line 528, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Requested tensor connection from unknown node: "dense_input:0".
Exception ignored in: <bound method BaseSession._Callable.__del__ of <tensorflow.python.client.session.BaseSession._Callable object at 0x000001E7749C5438>>
Traceback (most recent call last):
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonclientsession.py", line 1455, in __del__
self._session._session, self._handle, status)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonframeworkerrors_impl.py", line 528, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: No such callable handle: 2093487919952
The model is loaded into memory when I start running the code. To do this I created a globals object that loads the model the following way.
self.ModelName = ModelName
self.Model = load_model("Models/" + self.ModelName + '.mdl')
self.Model._make_predict_function()
To use the predict function it is run in a thread
predict = self.Model.predict(data, steps=10)
I know the data supplied is correct for I get a result if I just cut out the threading aspect out of my code and make my code into a single thread.
I cut out most of code since its split up into multiple files and as I tried to paste here stack overflow told me I had to much code.
If needed please let me know which sections of code would be most beneficial to post in as an edit.
python multithreading tensorflow
I have a saved model that I can generate a prediction when I run it on the main thread. When I try to use the same function in a thread I get the following error.
Note a summary of my code will be pasted after the error.
Exception in thread Thread-6:
Traceback (most recent call last):
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libthreading.py", line 916, in _bootstrap_inner
self.run()
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libthreading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "D:PiChessCoreComModule.py", line 49, in threader
b = Globals.moduleManager.GetPrediction(predictionSet)
File "D:PiChessCoreManagementModel.py", line 56, in GetPrediction
return self.Model.predict(data, steps=10)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonkerasenginetraining.py", line 1878, in predict
self, x, batch_size=batch_size, verbose=verbose, steps=steps)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonkerasenginetraining_arrays.py", line 295, in predict_loop
batch_outs = f(ins)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonkerasbackend.py", line 2983, in __call__
self._make_callable(feed_arrays, feed_symbols, symbol_vals, session)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonkerasbackend.py", line 2928, in _make_callable
callable_fn = session._make_callable_from_options(callable_opts)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonclientsession.py", line 1471, in _make_callable_from_options
return BaseSession._Callable(self, callable_options)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonclientsession.py", line 1425, in __init__
session._session, options_ptr, status)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonframeworkerrors_impl.py", line 528, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Requested tensor connection from unknown node: "dense_input:0".
Exception ignored in: <bound method BaseSession._Callable.__del__ of <tensorflow.python.client.session.BaseSession._Callable object at 0x000001E7749C5438>>
Traceback (most recent call last):
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonclientsession.py", line 1455, in __del__
self._session._session, self._handle, status)
File "C:Program Files (x86)Microsoft Visual StudioSharedPython36_64libsite-packagestensorflowpythonframeworkerrors_impl.py", line 528, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: No such callable handle: 2093487919952
The model is loaded into memory when I start running the code. To do this I created a globals object that loads the model the following way.
self.ModelName = ModelName
self.Model = load_model("Models/" + self.ModelName + '.mdl')
self.Model._make_predict_function()
To use the predict function it is run in a thread
predict = self.Model.predict(data, steps=10)
I know the data supplied is correct for I get a result if I just cut out the threading aspect out of my code and make my code into a single thread.
I cut out most of code since its split up into multiple files and as I tried to paste here stack overflow told me I had to much code.
If needed please let me know which sections of code would be most beneficial to post in as an edit.
python multithreading tensorflow
python multithreading tensorflow
asked Nov 22 at 19:20
Tolure
40411021
40411021
add a comment |
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53436994%2ftrouble-with-the-predict-function-of-my-model-while-in-a-separate-thread%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53436994%2ftrouble-with-the-predict-function-of-my-model-while-in-a-separate-thread%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown