That’s interesting. I can run your code sample with no issue locally. (Even after increasing the batch size drastically to (5000, 5000).
Which version of pytorch are you using?
It running this code consistently give you the error above?