Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI/Build] Avoid CUDA initialization #8534

Merged
merged 22 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix is_cuda_available probably not stateless
  • Loading branch information
DarkLight1337 committed Sep 17, 2024
commit a4feb861cf9215c128b834794b1d9c0c2f691576
4 changes: 4 additions & 0 deletions vllm/platforms/cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ def device_id_to_physical_device_id(device_id: int) -> int:
class CudaPlatform(Platform):
_enum = PlatformEnum.CUDA

@classmethod
def is_cuda_available(cls) -> bool:
return True

@classmethod
def get_device_capability(cls, device_id: int = 0) -> DeviceCapability:
physical_device_id = device_id_to_physical_device_id(device_id)
Expand Down
6 changes: 4 additions & 2 deletions vllm/platforms/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ def is_cpu(self) -> bool:
return self._enum == PlatformEnum.CPU

@classmethod
def is_cuda_available(cls, device_id: int = 0) -> bool:
return cls.get_device_capability(device_id=device_id) is not None
def is_cuda_available(cls) -> bool:
"""Stateless version of :func:`torch.cuda.is_available`."""
return False

@classmethod
def get_device_capability(
cls,
device_id: int = 0,
) -> Optional[DeviceCapability]:
"""Stateless version of :func:`torch.cuda.get_device_capability`."""
return None

@classmethod
Expand Down
4 changes: 4 additions & 0 deletions vllm/platforms/rocm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
class RocmPlatform(Platform):
_enum = PlatformEnum.ROCM

@classmethod
def is_cuda_available(cls) -> bool:
return True

@classmethod
@lru_cache(maxsize=8)
def get_device_capability(cls, device_id: int = 0) -> DeviceCapability:
Expand Down