2929class Worker :
3030
3131 def __init__ (self , fastvideo_args : FastVideoArgs , local_rank : int ,
32- rank : int , pipe ):
32+ rank : int , pipe , master_port : int ):
3333 self .fastvideo_args = fastvideo_args
3434 self .local_rank = local_rank
3535 self .rank = rank
3636 # TODO(will): don't hardcode this
3737 self .distributed_init_method = "env://"
3838 self .pipe = pipe
39-
39+ self . master_port = master_port
4040 self .init_device ()
4141
4242 # Init request dispatcher
@@ -76,7 +76,7 @@ def init_device(self) -> None:
7676 f"Unsupported device: { self .fastvideo_args .device_str } " )
7777
7878 os .environ ["MASTER_ADDR" ] = "localhost"
79- os .environ ["MASTER_PORT" ] = "29503"
79+ os .environ ["MASTER_PORT" ] = str ( self . master_port )
8080 os .environ ["LOCAL_RANK" ] = str (self .local_rank )
8181 os .environ ["RANK" ] = str (self .rank )
8282
@@ -191,7 +191,7 @@ def init_worker_distributed_environment(
191191
192192
193193def run_worker_process (fastvideo_args : FastVideoArgs , local_rank : int ,
194- rank : int , pipe ):
194+ rank : int , pipe , master_port : int ):
195195 # Add process-specific prefix to stdout and stderr
196196 process_name = mp .current_process ().name
197197 pid = os .getpid ()
@@ -206,8 +206,9 @@ def run_worker_process(fastvideo_args: FastVideoArgs, local_rank: int,
206206 logger .info ("Worker %d initializing..." ,
207207 rank ,
208208 local_main_process_only = False )
209+
209210 try :
210- worker = Worker (fastvideo_args , local_rank , rank , pipe )
211+ worker = Worker (fastvideo_args , local_rank , rank , pipe , master_port )
211212 logger .info ("Worker %d sending ready" , rank )
212213 pipe .send ({
213214 "status" : "ready" ,
0 commit comments