[Bugfix][Intel] Fix XPU Dockerfile Build (#7824)
Signed-off-by: tylertitsworth <tyler.titsworth@intel.com> Co-authored-by: youkaichao <youkaichao@126.com>
This commit is contained in:
@@ -42,6 +42,15 @@ try:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
is_xpu = False
|
||||
|
||||
try:
|
||||
import torch
|
||||
if hasattr(torch, 'xpu') and torch.xpu.is_available():
|
||||
is_xpu = True
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
is_cpu = False
|
||||
try:
|
||||
from importlib.metadata import version
|
||||
@@ -60,6 +69,9 @@ elif is_cuda:
|
||||
elif is_rocm:
|
||||
from .rocm import RocmPlatform
|
||||
current_platform = RocmPlatform()
|
||||
elif is_xpu:
|
||||
from .xpu import XPUPlatform
|
||||
current_platform = XPUPlatform()
|
||||
elif is_cpu:
|
||||
from .cpu import CpuPlatform
|
||||
current_platform = CpuPlatform()
|
||||
|
||||
@@ -8,6 +8,7 @@ class PlatformEnum(enum.Enum):
|
||||
CUDA = enum.auto()
|
||||
ROCM = enum.auto()
|
||||
TPU = enum.auto()
|
||||
XPU = enum.auto()
|
||||
CPU = enum.auto()
|
||||
UNSPECIFIED = enum.auto()
|
||||
|
||||
@@ -41,6 +42,9 @@ class Platform:
|
||||
def is_tpu(self) -> bool:
|
||||
return self._enum == PlatformEnum.TPU
|
||||
|
||||
def is_xpu(self) -> bool:
|
||||
return self._enum == PlatformEnum.XPU
|
||||
|
||||
def is_cpu(self) -> bool:
|
||||
return self._enum == PlatformEnum.CPU
|
||||
|
||||
|
||||
20
vllm/platforms/xpu.py
Normal file
20
vllm/platforms/xpu.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import torch
|
||||
|
||||
from .interface import DeviceCapability, Platform, PlatformEnum
|
||||
|
||||
|
||||
class XPUPlatform(Platform):
|
||||
_enum = PlatformEnum.XPU
|
||||
|
||||
@staticmethod
|
||||
def get_device_capability(device_id: int = 0) -> DeviceCapability:
|
||||
return DeviceCapability(major=int(
|
||||
torch.xpu.get_device_capability(device_id)['version'].split('.')
|
||||
[0]),
|
||||
minor=int(
|
||||
torch.xpu.get_device_capability(device_id)
|
||||
['version'].split('.')[1]))
|
||||
|
||||
@staticmethod
|
||||
def get_device_name(device_id: int = 0) -> str:
|
||||
return torch.xpu.get_device_name(device_id)
|
||||
Reference in New Issue
Block a user