TensorFlowLaboratory icon indicating copy to clipboard operation
TensorFlowLaboratory copied to clipboard

tf.queueRunner 读取tfrecord数据在GPU下的效率

Open juventi opened this issue 7 years ago • 1 comments

请问下有没有测过程序运行时GPU的使用效率? 我自己在用tfrecord和queue方式读写数据进行训练的时候, 如果: with tf.device('/gpu:0'): sess = tf.Session(config=tf.ConfigProto(allow_soft_placement=True)) 的话,GPU只使用了一点,20%,大部分仍然用了CPU去算; 如果强制GPU的话 with tf.device('/gpu:0'): sess = tf.Session() 会报如下错误,应该时某些任务不支持GPU上算导致, InvalidArgumentError (see above for traceback): Cannot assign a device to node 'batch': Could not satisfy explicit device specification '/device:GPU:0' because no supported kernel for GPU devices is available. Colocation Debug Info: Colocation group had the following types and devices: FIFOQueueV2: CPU Switch: CPU QueueDequeueManyV2: CPU QueueSizeV2: CPU QueueCloseV2: CPU QueueEnqueueV2: CPU [[Node: batch = QueueDequeueManyV2[component_types=[DT_FLOAT, DT_FLOAT], timeout_ms=-1, _device="/device:GPU:0"](batch/fifo_queue, batch/n)]]; 是不是tf的queue方式不支持GPU的运算?

但如果不用tfrecord和queue,把所有图像都一次性读进来,然后用顺序训练, 只用 with tf.device('/gpu:0'): sess = tf.Session() 时,GPU使用率超过85%,速度也比tfrecord和queue的方式快了几倍。

juventi avatar Oct 29 '17 06:10 juventi

https://www.tensorflow.org/versions/master/performance/datasets_performance 你可以看看这个,里面有个图讲了cpu和gpu工作时候的时间图。 你一次都读进来那只能是针对memory够的情况下吧。

Yumin-Sun-00 avatar Mar 19 '18 14:03 Yumin-Sun-00