我的訓練過程使用tfrecord格式的火車& eval數據集。TFRecordReader看起來非常慢,並且多線程閱讀不起作用
我測試閱讀器的基準,只有8000記錄/秒。和io速度(見iotop命令)只有400KB-500KB/s。
我使用的protobuf的CPP版本在這裏
如果可能的話,提供一個最小的可重複的例子(我們通常沒有時間來閱讀數百你的代碼的行)
def read_and_decode(filename_queue):
reader = tf.TFRecordReader()
_, serialized_example = reader.read(filename_queue)
return serialized_example
serialized_example = read_and_decode(filename_queue)
batch_serialized_example = tf.train.shuffle_batch(
[serialized_example],
batch_size=batch_size,
num_threads=thread_number,
capacity=capacity,
min_after_dequeue=min_after_dequeue)
features = tf.parse_example(
batch_serialized_example,
features={
"label": tf.FixedLenFeature([], tf.float32),
"ids": tf.VarLenFeature(tf.int64),
"values": tf.VarLenFeature(tf.float32),
})
您嘗試過其他嘗試的解決方案嗎?
我嘗試在tf.train.shuffle_batch中設置num_threads,但無法正常工作。
似乎當設置爲2個線程時,它工作在8000個記錄/秒,當放大線程數時,它變慢。 (我刪除了所有花費cpus的ops,只是讀取數據。)
我的服務器是24核心cpus。
您受CPU或磁盤限制嗎?做時間線可視化可以幫助看到瓶頸在哪裏 –
很高興再次見到你。 1)不,我不限制CPU的使用。 2)我的tfrecords文件存儲在本地磁盤驅動器中。這是表現的原因嗎? 3)我現在要做時間線。感謝您的建議。我稍後再更新。 – ericyue
這裏是我的基準腳本和時間軸結果(timeline.json原始文件inlcude)https://gist.github.com/ericyue/7705407a88e643f7ab380c6658f641e8 – ericyue