I’ve encountered the same problem recently.
If you’re using the docker to run the pytorch program, with high probability, it’s because the shared memory of docker is not big enough for running your program in the specified batchsize.
The solutions for this circumstance are:

use a smaller batchsize to train your model.
exit the current docker, and re-run the docker with specified “–shm-size=16g” or bigger depends on your machine.

Hope this could help those who have same problem.