Thank you for your suggestion! I tried this but this does not directly solve my use case. What I would want is essentially the Dataloader to not dynamically create a tensor for each batch, but write each batch into a predefined buffer.
If my loader looks like this:
loader = DataLoader(
    dataset,
    num_workers=7,
    shuffle=False
)
loader_iter = iter(loader)
buffer  # size of this is 2*num_workers

next(loader_iter) # this should write the new batch into the buffer directly

Is it possible to have a predefined buffer where each worker writes a batch into a position in the buffer?