Solve pytorch multiprocess valueerror: error initializing torch.distributed using env: //rendezvou… Error

error message: ValueError: Error initializing torch.distributed using env:// rendezvous: environment variable MASTER_ADDR expected, but not set
Solution 1:
Use in the code

import os

os.environ['MASTER_ADDR'] = 'localhost'
os.environ['MASTER_PORT'] = '5678'

Solution 2:

If you are running the command line, you can use:

export MASTER_ADDR=localhost
export MASTER_PORT=5678

Read More: