Data loading issue

for i, (input, target) in enumerate(train_loader):
# measure data loading time

data_time.update(time.time() - end)

some operations

end = time.time()

when doing this operation to measure the data loading time, sometimes the avg time start from around 0.06 and keep it in this level during training. In this situation, the training speed is fast. but sometimes the avg time start from more then 2 and then slowly decrease after each epoch and eventually become a small number after tens of epochs. I run the code in the same machine with the same dataset and the same number of workers. I was wondering what causes this problem and is there any solution?