@@ -32,22 +32,25 @@ def vllm_version_matches_substr(substr: str) -> bool:
32
32
33
33
def tpu_platform_plugin () -> Optional [str ]:
34
34
is_tpu = False
35
+ logger .debug ("Checking if TPU platform is available." )
35
36
try :
36
37
# While it's technically possible to install libtpu on a
37
38
# non-TPU machine, this is a very uncommon scenario. Therefore,
38
39
# we assume that libtpu is installed if and only if the machine
39
40
# has TPUs.
40
41
import libtpu # noqa: F401
41
42
is_tpu = True
42
- except Exception :
43
+ logger .debug ("Confirmed TPU platform is available." )
44
+ except Exception as e :
45
+ logger .debug ("TPU platform is not available because: %s" , str (e ))
43
46
pass
44
47
45
48
return "vllm.platforms.tpu.TpuPlatform" if is_tpu else None
46
49
47
50
48
51
def cuda_platform_plugin () -> Optional [str ]:
49
52
is_cuda = False
50
-
53
+ logger . debug ( "Checking if CUDA platform is available." )
51
54
try :
52
55
from vllm .utils import import_pynvml
53
56
pynvml = import_pynvml ()
@@ -60,9 +63,19 @@ def cuda_platform_plugin() -> Optional[str]:
60
63
# on a GPU machine, even if in a cpu build.
61
64
is_cuda = (pynvml .nvmlDeviceGetCount () > 0
62
65
and not vllm_version_matches_substr ("cpu" ))
66
+ if pynvml .nvmlDeviceGetCount () <= 0 :
67
+ logger .debug (
68
+ "CUDA platform is not available because no GPU is found." )
69
+ if vllm_version_matches_substr ("cpu" ):
70
+ logger .debug ("CUDA platform is not available because"
71
+ " vLLM is built with CPU." )
72
+ if is_cuda :
73
+ logger .debug ("Confirmed CUDA platform is available." )
63
74
finally :
64
75
pynvml .nvmlShutdown ()
65
76
except Exception as e :
77
+ logger .debug ("Exception happens when checking CUDA platform: %s" ,
78
+ str (e ))
66
79
if "nvml" not in e .__class__ .__name__ .lower ():
67
80
# If the error is not related to NVML, re-raise it.
68
81
raise e
@@ -75,84 +88,117 @@ def cuda_is_jetson() -> bool:
75
88
or os .path .exists ("/sys/class/tegra-firmware" )
76
89
77
90
if cuda_is_jetson ():
91
+ logger .debug ("Confirmed CUDA platform is available on Jetson." )
78
92
is_cuda = True
93
+ else :
94
+ logger .debug ("CUDA platform is not available because: %s" , str (e ))
79
95
80
96
return "vllm.platforms.cuda.CudaPlatform" if is_cuda else None
81
97
82
98
83
99
def rocm_platform_plugin () -> Optional [str ]:
84
100
is_rocm = False
85
-
101
+ logger . debug ( "Checking if ROCm platform is available." )
86
102
try :
87
103
import amdsmi
88
104
amdsmi .amdsmi_init ()
89
105
try :
90
106
if len (amdsmi .amdsmi_get_processor_handles ()) > 0 :
91
107
is_rocm = True
108
+ logger .debug ("Confirmed ROCm platform is available." )
92
109
finally :
93
110
amdsmi .amdsmi_shut_down ()
94
- except Exception :
111
+ except Exception as e :
112
+ logger .debug ("ROCm platform is not available because: %s" , str (e ))
95
113
pass
96
114
97
115
return "vllm.platforms.rocm.RocmPlatform" if is_rocm else None
98
116
99
117
100
118
def hpu_platform_plugin () -> Optional [str ]:
101
119
is_hpu = False
120
+ logger .debug ("Checking if HPU platform is available." )
102
121
try :
103
122
from importlib import util
104
123
is_hpu = util .find_spec ('habana_frameworks' ) is not None
105
- except Exception :
124
+ if is_hpu :
125
+ logger .debug ("Confirmed HPU platform is available." )
126
+ else :
127
+ logger .debug ("HPU platform is not available because "
128
+ "habana_frameworks is not found." )
129
+ except Exception as e :
130
+ logger .debug ("HPU platform is not available because: %s" , str (e ))
106
131
pass
107
132
108
133
return "vllm.platforms.hpu.HpuPlatform" if is_hpu else None
109
134
110
135
111
136
def xpu_platform_plugin () -> Optional [str ]:
112
137
is_xpu = False
113
-
138
+ logger . debug ( "Checking if XPU platform is available." )
114
139
try :
115
140
# installed IPEX if the machine has XPUs.
116
141
import intel_extension_for_pytorch # noqa: F401
117
142
import oneccl_bindings_for_pytorch # noqa: F401
118
143
import torch
119
144
if hasattr (torch , 'xpu' ) and torch .xpu .is_available ():
120
145
is_xpu = True
121
- except Exception :
146
+ logger .debug ("Confirmed XPU platform is available." )
147
+ except Exception as e :
148
+ logger .debug ("XPU platform is not available because: %s" , str (e ))
122
149
pass
123
150
124
151
return "vllm.platforms.xpu.XPUPlatform" if is_xpu else None
125
152
126
153
127
154
def cpu_platform_plugin () -> Optional [str ]:
128
155
is_cpu = False
156
+ logger .debug ("Checking if CPU platform is available." )
129
157
try :
130
158
is_cpu = vllm_version_matches_substr ("cpu" )
159
+ if is_cpu :
160
+ logger .debug ("Confirmed CPU platform is available because"
161
+ " vLLM is built with CPU." )
131
162
if not is_cpu :
132
163
import platform
133
164
is_cpu = platform .machine ().lower ().startswith ("arm" )
165
+ if is_cpu :
166
+ logger .debug ("Confirmed CPU platform is available"
167
+ " because the machine is ARM." )
134
168
135
- except Exception :
169
+ except Exception as e :
170
+ logger .debug ("CPU platform is not available because: %s" , str (e ))
136
171
pass
137
172
138
173
return "vllm.platforms.cpu.CpuPlatform" if is_cpu else None
139
174
140
175
141
176
def neuron_platform_plugin () -> Optional [str ]:
142
177
is_neuron = False
178
+ logger .debug ("Checking if Neuron platform is available." )
143
179
try :
144
180
import transformers_neuronx # noqa: F401
145
181
is_neuron = True
146
- except ImportError :
182
+ logger .debug ("Confirmed Neuron platform is available because"
183
+ " transformers_neuronx is found." )
184
+ except ImportError as e :
185
+ logger .debug ("Neuron platform is not available because: %s" , str (e ))
147
186
pass
148
187
149
188
return "vllm.platforms.neuron.NeuronPlatform" if is_neuron else None
150
189
151
190
152
191
def openvino_platform_plugin () -> Optional [str ]:
153
192
is_openvino = False
193
+ logger .debug ("Checking if OpenVINO platform is available." )
154
194
with suppress (Exception ):
155
195
is_openvino = vllm_version_matches_substr ("openvino" )
196
+ if is_openvino :
197
+ logger .debug ("Confirmed OpenVINO platform is available"
198
+ " because vLLM is built with OpenVINO." )
199
+ if not is_openvino :
200
+ logger .debug ("OpenVINO platform is not available because"
201
+ " vLLM is not built with OpenVINO." )
156
202
157
203
return "vllm.platforms.openvino.OpenVinoPlatform" if is_openvino else None
158
204
0 commit comments