One simple solution is you can lower the batch size until everything works.
As what @ptrblck has said its a cpu allocation issue, try using gpu by calling .cuda() to your model and dataset.
And if you still get error in this case by using gpu then try freeing memory allocated at gpu using torch.cuda.empty_cache() after every epoch or batch iteration.
Other wise I’d recommend you using gradient accumulation, more about it here 48, using this you can your train model using data with bigger batch size even if your gpu doesn’t have that much memory.