TensorFlow C ++,运行时问题

TensorFlow C ++,运行时问题

问题描述:

我已经使用TensorFlow python创建了一个模型.现在,我已经用C ++加载了模型,并使用session-> Run(输入输入张量)运行它.该代码已被正确编译和链接,但是一旦在运行时到达会话-> Run,它就不会继续进行,也不会创建任何错误消息!看起来它永远运行!我还检查了CPU使用率,但它也没有指示任何密集的计算!

I have created a model using TensorFlow python. Now I have loaded the model in C++ and run it using session->Run (feeding input tensors). The code is complied and linked well, however as soon as it reaches the session->Run during the run time, It doesn't proceed further, and it doesn't create any error message either! It looks like it runs forever! I also checked the CPU usage, but it does not also indicate any intensive computation!

当TensorFlow程序永久阻塞时,一个常见的问题是,该步骤被阻塞在 q.dequeue_many()

When a TensorFlow program blocks forever, one common issue is that the step is blocked on an empty queue in a q.dequeue() or q.dequeue_many() op.

一种可能性是您的Python模型依赖于预取线程(源自 tf.train.QueueRunner 对象).许多输入内容(例如,使用 tf.TFRecordReader )和批处理(例如,使用

One possibility is that your Python model depends on prefetching threads (derived from tf.train.QueueRunner objects). Many of the input reading (e.g. using tf.TFRecordReader), and batching (e.g. using tf.train.batch()) pipelines implicitly create queues and queue runners.

如果您必须运行 tf.在Python程序中运行train.start_queue_runners() ,那么您将需要通过分叉线程来运行相应的 q.enqueue(),从而在C ++代码中执行等效的操作>操作.另外,您可以准备C ++程序中的输入并提供图形,以使您尝试运行的操作不依赖于队列的出队元素.

If you had to run tf.train.start_queue_runners() in your Python program, then you will need to do the equivalent thing in your C++ code, by forking threads to run the appropriate q.enqueue() ops. Alternatively, you can prepare the input in your C++ program and feed the graph so that the operations you are trying to run do not depend on dequeuing elements for a queue.