BiB*_*iBi 6 gpu nvidia neural-network deep-learning tensorflow
我正在使用与Titan-X GPU的张量流,我注意到,当我运行CIFAR10示例时,Volatile GPU-utilization它几乎恒定在30%左右,而当我训练自己的模型时,Volatile GPU-utilization它远非稳定,它几乎总是0%并且在80%/ 90%之前飙升,然后再回到0%,一遍又一遍.
我认为这种行为是由于我的数据反馈到网络(我的每一步,这花了一些时间后获取数据)的方式.但是在实现了一个队列来提供数据并避免步骤之间的这种延迟之后,问题仍然存在(请参阅下面的排队系统).
任何的想法?
batch = 128 # size of the batch
x = tf.placeholder("float32", [None, n_steps, n_input])
y = tf.placeholder("float32", [None, n_classes])
# with a capacity of 100 batches, the bottleneck should not be the data feeding
queue = tf.RandomShuffleQueue(capacity=100*batch,
min_after_dequeue=80*batch,
dtypes=[tf.float32, tf.float32],
shapes=[[n_steps, n_input], [n_classes]])
enqueue_op = queue.enqueue_many([x, y])
X_batch, Y_batch = queue.dequeue_many(batch)
sess = tf.Session()
def load_and_enqueue(data):
while True:
X, Y = data.get_next_batch(batch)
sess.run(enqueue_op, feed_dict={x: X, y: Y})
train_thread = threading.Thread(target=load_and_enqueue, args=(data))
train_thread.daemon = True
train_thread.start()
for _ in xrange(max_iter):
sess.run(train_op)
Run Code Online (Sandbox Code Playgroud)
BiB*_*iBi 11
在做了一些实验之后,我找到了答案,所以我发布它,因为它可能对其他人有用.
首先,get_next_batch比大约快15倍train_op(感谢Eric Platon指出这一点).
但是,我认为队列正在被排除,capacity并且只有在训练开始之后才会开始.因此,我认为,即使get_next_batch速度较慢,队列也应该至少在开始时隐藏这种延迟,因为它包含capacity示例,并且只有在达到min_after_dequeue低于的数据后才需要获取新数据capacity,并且它将导致某种程度上稳定的GPU利用率.
但实际上,一旦队列到达min_after_dequeue示例,训练就会开始.因此,一旦队列到达min_after_dequeue运行示例的队列,队列就会出列train_op,并且由于提供队列的时间比执行时间慢15倍train_op,因此队列中的元素数量min_after_dequeue在第一次迭代后立即下降到正下方.的train_op和train_op必须等待队列再次达到min_after_dequeue例子.
当我强制train_op等待队列被送到capacity(有capacity = 100*batch)而不是在达到min_after_dequeue(有min_after_dequeue=80*batch)时自动启动时,GPU利用率稳定了10秒,然后回到0%,这是可以理解的,因为队列到达min_after_dequeue例如,不到10秒钟.
| 归档时间: |
|
| 查看次数: |
3664 次 |
| 最近记录: |