Implementation:Vllm project Vllm Collect Env
| Knowledge Sources | |
|---|---|
| Domains | Diagnostics, Configuration |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
Collects comprehensive system environment information for debugging and issue reporting, gathering details about PyTorch, CUDA, ROCm, GPU topology, Python packages, and vLLM configuration.
Description
collect_env.py is a diagnostic utility adapted from PyTorch's torch.utils.collect_env. It executes system commands (nvidia-smi, lscpu, pip list, conda list, etc.) via subprocess, parses their outputs, and assembles a SystemEnv named tuple containing version information for all relevant system components. The collected data includes torch version, CUDA/ROCm versions, GPU models, driver versions, compiler versions (gcc, clang, cmake), Python packages, and vLLM-specific fields such as build flags and GPU topology.
The module also collects vLLM environment variables by iterating over the registered environment_variables dictionary from vllm.envs, providing a complete snapshot of the runtime configuration.
Usage
This file is used when filing bug reports or diagnosing platform-specific issues. Users run it directly as a script (python vllm/collect_env.py) or it is invoked programmatically to generate standardized environment reports. The output format matches PyTorch conventions, making it familiar to both users and maintainers.
Code Reference
Source Location
- Repository: vllm
- File: vllm/collect_env.py
- Lines: 1-851
Signature
SystemEnv = namedtuple("SystemEnv", [
"torch_version", "is_debug_build", "cuda_compiled_version",
"gcc_version", "clang_version", "cmake_version", "os",
"libc_version", "python_version", "python_platform",
"is_cuda_available", "cuda_runtime_version", "cuda_module_loading",
"nvidia_driver_version", "nvidia_gpu_models", "cudnn_version",
"pip_version", "pip_packages", "conda_packages",
"hip_compiled_version", "hip_runtime_version", "miopen_runtime_version",
"caching_allocator_config", "is_xnnpack_available", "cpu_info",
"rocm_version", "vllm_version", "vllm_build_flags",
"gpu_topo", "env_vars",
])
def run(command) -> tuple[int, str, str]: ...
def run_and_read_all(run_lambda, command) -> str | None: ...
def run_and_parse_first_match(run_lambda, command, regex) -> str | None: ...
def get_conda_packages(run_lambda, patterns=None) -> str | None: ...
def get_gcc_version(run_lambda) -> str | None: ...
def get_clang_version(run_lambda) -> str | None: ...
def get_cmake_version(run_lambda) -> str | None: ...
def get_nvidia_driver_version(run_lambda) -> str | None: ...
def get_gpu_info(run_lambda) -> str: ...
Import
# Run as a standalone script:
# python vllm/collect_env.py
# Or import programmatically:
from vllm.collect_env import get_env_info
env_info = get_env_info()
print(env_info)
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| (system state) | environment | Yes | The system environment including installed packages, GPU drivers, and hardware |
| CONDA_EXE | env var | No | Path to conda executable (defaults to "conda") |
| vllm.envs.environment_variables | dict | No | Dictionary of vLLM environment variable definitions to collect |
Outputs
| Name | Type | Description |
|---|---|---|
| SystemEnv | namedtuple | Comprehensive system environment snapshot containing all collected information |
| stdout | text | Formatted human-readable environment report when run as a script |
Usage Examples
# Run from command line to generate a diagnostic report
# $ python vllm/collect_env.py
# Example output (truncated):
# PyTorch version: 2.5.0+cu124
# Is debug build: False
# CUDA used to build PyTorch: 12.4
# GPU models and configuration: NVIDIA A100-SXM4-80GB
# vLLM Version: 0.7.0
# vLLM Build Flags: CUDA Archs: 8.0; ROCm: Disabled; Neuron: Disabled
# Programmatic usage
from vllm.collect_env import get_env_info
env = get_env_info()
print(f"CUDA available: {env.is_cuda_available}")
print(f"GPU: {env.nvidia_gpu_models}")
print(f"vLLM version: {env.vllm_version}")