@@ -2,6 +2,8 @@ Getting Started with Distributed Data Parallel
2
2
=================================================
3
3
**Author **: `Shen Li <https://mrshenli.github.io/ >`_
4
4
5
+ **Edited by **: `Joe Zhu <https://github.com/gunandrose4u >`_
6
+
5
7
Prerequisites:
6
8
7
9
- `PyTorch Distributed Overview <../beginner/dist_overview.html >`__
@@ -68,6 +70,7 @@ be found in
68
70
.. code :: python
69
71
70
72
import os
73
+ import sys
71
74
import tempfile
72
75
import torch
73
76
import torch.distributed as dist
@@ -79,12 +82,26 @@ be found in
79
82
80
83
81
84
def setup (rank , world_size ):
82
- os.environ[' MASTER_ADDR' ] = ' localhost'
83
- os.environ[' MASTER_PORT' ] = ' 12355'
84
-
85
- # initialize the process group
86
- dist.init_process_group(" gloo" , rank = rank, world_size = world_size)
85
+ if sys.platform == ' win32' :
86
+ # Distributed package only covers collective communications with Gloo
87
+ # backend and FileStore on Windows platform. Set init_method parameter
88
+ # in init_process_group to a local file.
89
+ # Example init_method="file:///f:/libtmp/some_file"
90
+ init_method= " file:///{your local file path}"
91
+
92
+ # initialize the process group
93
+ dist.init_process_group(
94
+ " gloo" ,
95
+ init_method = init_method,
96
+ rank = rank,
97
+ world_size = world_size
98
+ )
99
+ else :
100
+ os.environ[' MASTER_ADDR' ] = ' localhost'
101
+ os.environ[' MASTER_PORT' ] = ' 12355'
87
102
103
+ # initialize the process group
104
+ dist.init_process_group(" gloo" , rank = rank, world_size = world_size)
88
105
89
106
def cleanup ():
90
107
dist.destroy_process_group()
0 commit comments