One 、 Click on Run--->Edit Configuration---> Select the program you want to run with the command line arguments , stay parameters Enter command line parameters in .
https://blog.csdn.net/weixin_44457930/article/details/120572174
Two 、 Use the environment variables that need to be used os.environ Add to .py In the code file .
The following Command line utilize export Set the environment variable
export MASTER_ADDR=localhost
export MASTER_PORT=5678
Rewrite as follows with os.environ Set the environment variable
import os
os.environ['MASTER_ADDR'] = 'localhost'
os.environ['MASTER_PORT'] = '5678'
Otherwise, an error will be reported :ValueError: Error initializing torch.distributed using env:// rendezvous: environment variable MASTER_ADDR( Or others ) expected, but not set
https://blog.csdn.net/weixin_41529093/article/details/123704238