I’m still unsure, what might be causing the issue, as this code snippet works fine for me:
import torch
from torch.utils.data import Dataset, DataLoader, TensorDataset

print(torch.__version__)
dataset = TensorDataset(torch.randn(100, 1), torch.randn(100, 1))
loader = DataLoader(dataset, batch_size=25, num_workers=2, persistent_workers=True)

for data, target in loader:
    print(data.shape)

Output:
1.9.0+cu111
torch.Size([25, 1])
torch.Size([25, 1])
torch.Size([25, 1])
torch.Size([25, 1])

Are you seeing the same issue using my code?