@ptrblck actually I forgot to mention I was using the PyTorch Docker Image when I get the behavior mentioned in the question.
I just tested on a host machine and rightly so it does raise an error.
Seems the error happens on Docker image.