Skip to content

vllm.utils.platform_utils

Functions:

cuda_get_device_properties(device, names, init_cuda=False)

Get specified CUDA device property values without initializing CUDA in the current process.

Source code in vllm/utils/platform_utils.py
def cuda_get_device_properties(
    device, names: Sequence[str], init_cuda=False
) -> tuple[Any, ...]:
    """Get specified CUDA device property values without initializing CUDA in
    the current process."""
    if init_cuda or cuda_is_initialized():
        props = torch.cuda.get_device_properties(device)
        return tuple(getattr(props, name) for name in names)

    # Run in subprocess to avoid initializing CUDA as a side effect.
    mp_ctx = multiprocessing.get_context("fork")
    with ProcessPoolExecutor(max_workers=1, mp_context=mp_ctx) as executor:
        return executor.submit(cuda_get_device_properties, device, names, True).result()

cuda_is_initialized()

Check if CUDA is initialized.

Source code in vllm/utils/platform_utils.py
def cuda_is_initialized() -> bool:
    """Check if CUDA is initialized."""
    if not torch.cuda._is_compiled():
        return False
    return torch.cuda.is_initialized()

is_uva_available() cached

Check if Unified Virtual Addressing (UVA) is available.

Source code in vllm/utils/platform_utils.py
@cache
def is_uva_available() -> bool:
    """Check if Unified Virtual Addressing (UVA) is available."""
    from vllm.platforms import current_platform

    if current_platform.is_cpu():
        return True
    # UVA requires pinned memory. Under NVIDIA Confidential Computing the
    # device-side view of pinned host memory is not coherent (the GPU reads a
    # stale snapshot), so treat UVA as unavailable and fall back to explicit
    # copies (see vllm.v1.conf_compute_utils).
    return is_pin_memory_available() and not current_platform.is_confidential_compute()

num_compute_units(device_id=0) cached

Get the number of compute units of the current device.

Source code in vllm/utils/platform_utils.py
@cache
def num_compute_units(device_id: int = 0) -> int:
    """Get the number of compute units of the current device."""
    from vllm.platforms import current_platform

    return current_platform.num_compute_units(device_id)

xpu_is_initialized()

Check if XPU is initialized.

Source code in vllm/utils/platform_utils.py
def xpu_is_initialized() -> bool:
    """Check if XPU is initialized."""
    if not torch.xpu._is_compiled():
        return False
    return torch.xpu.is_initialized()