mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-10 07:04:53 +08:00
[Bugfix] Always set RAY_ADDRESS for Ray actor before spawn (#21540)
Signed-off-by: Rui Qiao <ruisearch42@gmail.com>
This commit is contained in:
parent
cea96a0156
commit
c7742d6113
@ -2883,26 +2883,27 @@ def _maybe_force_spawn():
|
||||
if os.environ.get("VLLM_WORKER_MULTIPROC_METHOD") == "spawn":
|
||||
return
|
||||
|
||||
reason = None
|
||||
if cuda_is_initialized():
|
||||
reason = "CUDA is initialized"
|
||||
elif xpu_is_initialized():
|
||||
reason = "XPU is initialized"
|
||||
elif is_in_ray_actor():
|
||||
reasons = []
|
||||
if is_in_ray_actor():
|
||||
# even if we choose to spawn, we need to pass the ray address
|
||||
# to the subprocess so that it knows how to connect to the ray cluster.
|
||||
# env vars are inherited by subprocesses, even if we use spawn.
|
||||
import ray
|
||||
os.environ["RAY_ADDRESS"] = ray.get_runtime_context().gcs_address
|
||||
reason = "In a Ray actor and can only be spawned"
|
||||
reasons.append("In a Ray actor and can only be spawned")
|
||||
|
||||
if reason is not None:
|
||||
if cuda_is_initialized():
|
||||
reasons.append("CUDA is initialized")
|
||||
elif xpu_is_initialized():
|
||||
reasons.append("XPU is initialized")
|
||||
|
||||
if reasons:
|
||||
logger.warning(
|
||||
"We must use the `spawn` multiprocessing start method. "
|
||||
"Overriding VLLM_WORKER_MULTIPROC_METHOD to 'spawn'. "
|
||||
"See https://docs.vllm.ai/en/latest/usage/"
|
||||
"troubleshooting.html#python-multiprocessing "
|
||||
"for more information. Reason: %s", reason)
|
||||
"for more information. Reasons: %s", "; ".join(reasons))
|
||||
os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn"
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user