I have divided my training data into multiple tf-record files, and read them using this piece of code:
SHUFFLE_BUFFER = 64
PREFETCH = 256
dataset = tf.data.TFRecordDataset(filenames)
dataset = dataset.shuffle(SHUFFLE_BUFFER)
dataset = dataset.map(_parse_image_function, num_parallel_calls=tf.data.experimental.AUTOTUNE)
dataset = dataset.batch(BATCH_SIZE)
dataset = dataset.prefetch(PREFETCH)
dataset = dataset.repeat()
This dataset is fed directly to model.fit(dataset).
The first PREFETCH samples are loaded quickly, and GPU utilization is constantly above 80%. However, after that the fast reading seems to stop, GPU utilization drops, and training time slows down massively. Anyone know what might be going wrong?