Trouble with the predict function of my model while in a separate thread












0














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.










share|improve this question



























    0














    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.










    share|improve this question

























      0












      0








      0







      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.










      share|improve this question













      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 22 at 19:20









      Tolure

      40411021




      40411021





























          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
          });


          }
          });














          draft saved

          draft discarded


















          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
















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Contact image not getting when fetch all contact list from iPhone by CNContact

          count number of partitions of a set with n elements into k subsets

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks