vllm.utils.system_utils ¶
_add_prefix ¶
Add colored prefix to file output for log decoration.
Source code in vllm/utils/system_utils.py
_maybe_force_spawn ¶
Check if we need to force the use of the spawn multiprocessing start method.
Source code in vllm/utils/system_utils.py
decorate_logs ¶
decorate_logs(process_name: str | None = None) -> None
Decorate stdout/stderr with process name and PID prefix.
Source code in vllm/utils/system_utils.py
find_loaded_library ¶
According to according to https://man7.org/linux/man-pages/man5/proc_pid_maps.5.html, the file /proc/self/maps contains the memory maps of the process, which includes the shared libraries loaded by the process. We can use this file to find the path of the loaded library.
Source code in vllm/utils/system_utils.py
get_mp_context ¶
Get a multiprocessing context with a particular method (spawn or fork). By default we follow the value of the VLLM_WORKER_MULTIPROC_METHOD to determine the multiprocessing method (default is fork). However, under certain conditions, we may enforce spawn and override the value of VLLM_WORKER_MULTIPROC_METHOD.
Source code in vllm/utils/system_utils.py
kill_process_tree ¶
kill_process_tree(pid: int)
Kills all descendant processes of the given pid by sending SIGKILL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pid | int | Process ID of the parent process | required |
Source code in vllm/utils/system_utils.py
set_env_var ¶
Temporarily set an environment variable.
Source code in vllm/utils/system_utils.py
set_process_title ¶
Set the current process title with optional suffix.
Source code in vllm/utils/system_utils.py
set_ulimit ¶
set_ulimit(target_soft_limit: int = 65535)
Source code in vllm/utils/system_utils.py
suppress_stdout ¶
Suppress stdout from C libraries at the file descriptor level.
Only suppresses stdout, not stderr, to preserve error messages. Suppression is disabled when VLLM_LOGGING_LEVEL is set to DEBUG.
Example
with suppress_stdout(): # C library calls that would normally print to stdout torch.distributed.new_group(ranks, backend="gloo")
Source code in vllm/utils/system_utils.py
unique_filepath ¶
Generate a unique file path by trying incrementing integers.
Note: This function has a TOCTOU race condition. Caller should use atomic operations (e.g., open with 'x' mode) when creating the file to ensure thread safety.
Source code in vllm/utils/system_utils.py
update_environment_variables ¶
Update multiple environment variables with logging.