Tensorflow Enqueue operation was cancelled

前端 未结 3 1608
甜味超标
甜味超标 2021-02-04 10:41

I had built a convolutional neural network in tensorflow. It is trained and now I am unpacking it and performing evaluations.

import main
import Process
import I         


        
相关标签:
3条回答
  • 2021-02-04 10:50

    Everything works correctly and the problem happens at the very last stage when python tries to kill threads. To do this properly you should create a train.Coordinator and pass it to your queue_runner (no need to pass sess, as default session will be used

    with tf.Session() as sess:
        coord = tf.train.Coordinator()
        threads = tf.train.start_queue_runners(coord=coord)
        // do your things
        coord.request_stop()
        coord.join(threads)
    
    0 讨论(0)
  • 2021-02-04 10:56

    Update from chat -- the program runs successfully, and the messages that are printed are due to Python killing threads while they are running as the process exits.

    The messages are harmless but it's possible to avoid them by stopping threads manually using pattern below.

    coord = tf.train.Coordinator()
    threads = tf.train.start_queue_runners(sess=sess, coord=coord)
    <do stuff>
    coord.request_stop()
    coord.join(threads)
    
    0 讨论(0)
  • 2021-02-04 11:08

    a way to add coord with exception handling:

    coord = tf.train.Coordinator()
    threads = tf.train.start_queue_runners(sess, coord)
    
    try:
        while not coord.should_stop():
    
            #doing things here
    
    except tf.errors.OutOfRangeError:
        print("things done")
    
    finally:
        coord.request_stop()
    

    then bug fixed :-)

    0 讨论(0)
提交回复
热议问题