One error I noticed is that, when using spawn, it will pass the rank as the first argument to the target function, followed by the args you provided. So the signature of the train function should be train(rank, args).
But above does not seem to be the cause of the logged error. That error does not seem to be PyTorch related, see this discussion: https://stackoverflow.com/questions/45720153/python-multiprocessing-error-attributeerror-module-main-has-no-attribute 9