Thanks for your answer! I am working with video data which are quite heavy. As you see in my custom VideoDataset below,  I am using a caching dictionary in my __get_item__ method.
When the batch is invoked by the DataLoader, the cached item would be returned. I wonder if by keeping transferring the batch to GPU would result in a OOM.
Isn’t PyTorch already flushing the unused batches in GPU? Or do you think it is a better idea to transfer the items to GPU within the `Dataset’ class, even though I read it is not a great idea?
Thanks for your hints!
class VideoDataset(torch.utils.data.Dataset):

  def __init__(self, data_path, classes, caching_dict=None, transforms=None, n_frames=None):
    super(VideoDataset, self).__init__()

    self.data_path = data_path
    self.classes = classes

    self.transforms = transforms
    self.n_frames = n_frames

    self.caching_dict = caching_dict

  def read_video(self, path):

    vr = VideoReader(path)

    if len(vr) >= self.n_frames:

      idxs = np.linspace(0, len(vr), self.n_frames, endpoint=False, dtype=np.int)
      frames = []
      for i in idxs:
        if self.transforms:
          frames.append(self.transforms(vr[i].asnumpy()))
        else:
          frames.append(vr[i].asnumpy())

      return torch.stack(frames, dim=0)
    else:
      print(f'N frames specified: {self.n_frames} must be less than number: {len(vr)} of video frames for video: {path}. Skipping video')

  def __getitem__(self, index):

    v_path, label = self.data_path[index]
    if self.caching_dict is not None:
      if index not in self.caching_dict:
        self.caching_dict[index] = self.read_video(v_path), self.classes[label]
      return self.caching_dict[index]
    else:
      return self.read_video(v_path), self.classes[label]

  def __len__(self): return len(self.data_path)