@@ -1119,34 +1119,9 @@ def xpu_is_initialized() -> bool:
11191119 return torch .xpu .is_initialized ()
11201120
11211121
1122- def maybe_force_spawn () -> None :
1123- """Check if we need to force the use of the `spawn` multiprocessing start
1124- method.
1125- """
1126- if os .environ .get ("FASTVIDEO_WORKER_MULTIPROC_METHOD" ) == "spawn" :
1127- return
1128-
1129- reasons = []
1130-
1131- from fastvideo .worker .ray_utils import is_in_ray_actor
1132- if is_in_ray_actor ():
1133- # even if we choose to spawn, we need to pass the ray address
1134- # to the subprocess so that it knows how to connect to the ray cluster.
1135- # env vars are inherited by subprocesses, even if we use spawn.
1136- import ray
1137- os .environ ["RAY_ADDRESS" ] = ray .get_runtime_context ().gcs_address
1138- reasons .append ("In a Ray actor and can only be spawned" )
1139-
1140- if cuda_is_initialized ():
1141- reasons .append ("CUDA is initialized" )
1142- elif xpu_is_initialized ():
1143- reasons .append ("XPU is initialized" )
1144-
1145- if reasons :
1146- logger .warning (
1147- "We must use the `spawn` multiprocessing start method. "
1148- "Overriding FASTVIDEO_WORKER_MULTIPROC_METHOD to 'spawn'. "
1149- "Reasons: %s" , "; " .join (reasons ))
1122+ def force_spawn () -> None :
1123+ if os .environ .get ("FASTVIDEO_WORKER_MULTIPROC_METHOD" ) == "fork" :
1124+ logger .warning ("We must use the `spawn` multiprocessing start method." )
11501125 os .environ ["FASTVIDEO_WORKER_MULTIPROC_METHOD" ] = "spawn"
11511126
11521127
@@ -1157,7 +1132,7 @@ def get_mp_context() -> BaseContext:
11571132 certain conditions, we may enforce spawn and override the value of
11581133 FASTVIDEO_WORKER_MULTIPROC_METHOD.
11591134 """
1160- maybe_force_spawn ()
1135+ force_spawn ()
11611136 mp_method = envs .FASTVIDEO_WORKER_MULTIPROC_METHOD
11621137 return multiprocessing .get_context (mp_method )
11631138
0 commit comments