Skip to content

Add cache to cuda get_device_capability #19436

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

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
4 changes: 3 additions & 1 deletion vllm/platforms/cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import os
from datetime import timedelta
from functools import wraps
from functools import cache, wraps
from typing import TYPE_CHECKING, Callable, Optional, TypeVar, Union

import torch
Expand Down Expand Up @@ -389,6 +389,7 @@ def stateless_init_device_torch_dist_pg(
class NvmlCudaPlatform(CudaPlatformBase):

@classmethod
@cache
@with_nvml_context
def get_device_capability(cls,
device_id: int = 0
Expand Down Expand Up @@ -486,6 +487,7 @@ def log_warnings(cls):
class NonNvmlCudaPlatform(CudaPlatformBase):

@classmethod
@cache
def get_device_capability(cls, device_id: int = 0) -> DeviceCapability:
major, minor = torch.cuda.get_device_capability(device_id)
return DeviceCapability(major=major, minor=minor)
Expand Down