Skip to content

Commit b77c7d3

Browse files
[BugFix] Fix ray import error mem cleanup bug (vllm-project#21381)
Signed-off-by: Travis Johnson <[email protected]> Signed-off-by: Joe Runde <[email protected]> Co-authored-by: Travis Johnson <[email protected]>
1 parent 35bc8bd commit b77c7d3

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

vllm/config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,10 +2137,11 @@ def __post_init__(self) -> None:
21372137
elif (current_platform.is_cuda()
21382138
and cuda_device_count_stateless() < self.world_size):
21392139
if not ray_found:
2140-
raise ValueError("Unable to load Ray which is "
2140+
raise ValueError("Unable to load Ray: "
2141+
f"{ray_utils.ray_import_err}. Ray is "
21412142
"required for multi-node inference, "
21422143
"please install Ray with `pip install "
2143-
"ray`.") from ray_utils.ray_import_err
2144+
"ray`.")
21442145
backend = "ray"
21452146
elif self.data_parallel_backend == "ray":
21462147
logger.info("Using ray distributed inference because "

vllm/executor/ray_utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ def override_env_vars(self, vars: Dict[str, str]):
145145

146146
except ImportError as e:
147147
ray = None # type: ignore
148-
ray_import_err = e
148+
# only capture string to avoid variable references in the traceback that can
149+
# prevent garbage collection in some cases
150+
ray_import_err = str(e)
149151
RayWorkerWrapper = None # type: ignore
150152

151153

@@ -157,8 +159,8 @@ def ray_is_available() -> bool:
157159
def assert_ray_available():
158160
"""Raise an exception if Ray is not available."""
159161
if ray is None:
160-
raise ValueError("Failed to import Ray, please install Ray with "
161-
"`pip install ray`.") from ray_import_err
162+
raise ValueError(f"Failed to import Ray: {ray_import_err}."
163+
"Please install Ray with `pip install ray`.")
162164

163165

164166
def _verify_bundles(placement_group: "PlacementGroup",

0 commit comments

Comments
 (0)