Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion vllm/utils/platform_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def xpu_is_initialized() -> bool:
return torch.xpu.is_initialized()


def get_cu_count(cls, device_id: int = 0) -> int:
def get_cu_count(device_id: int = 0) -> int:
"""Returns the total number of compute units (CU) on single GPU."""
return torch.cuda.get_device_properties(device_id).multi_processor_count
Comment on lines +27 to 29
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

While removing the unused cls parameter is correct, the function can be further improved. The direct call to torch.cuda.get_device_properties will initialize the CUDA context, which can cause issues in multiprocessing environments. This file provides a safer utility, cuda_get_device_properties, which avoids this side effect. Using it here would make the function more robust.

Suggested change
def get_cu_count(device_id: int = 0) -> int:
"""Returns the total number of compute units (CU) on single GPU."""
return torch.cuda.get_device_properties(device_id).multi_processor_count
def get_cu_count(device_id: int = 0) -> int:
"""Returns the total number of compute units (CU) on single GPU."""
return cuda_get_device_properties(device_id, ("multi_processor_count",))[0]


Expand Down