A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 16, 02:00 UTC
[HPU][Bugfix] Don't use /dev/accel/accel0 for HPU autodetection in setup.py (#12046)
Signed-off-by: Konrad Zawora <kzawora@habana.ai>
Konrad Zawora committed
Jan 15, 2025 at 03:59 UTC
1a51b9f87226b2290c78c65c1de0f585d31f17ce
1 file changed
+12
-7
setup.py
+12
-7
@@ -324,21 +324,26 @@ class repackage_wheel(build_ext):
324
325
326
def _is_hpu() -> bool:
327
- is_hpu_available = True
327
+ # if VLLM_TARGET_DEVICE env var was set explicitly, skip HPU autodetection
328
+ if os.getenv("VLLM_TARGET_DEVICE", None) == VLLM_TARGET_DEVICE:
329
+ return VLLM_TARGET_DEVICE == "hpu"
330
+
331
+ # if VLLM_TARGET_DEVICE was not set explicitly, check if hl-smi succeeds,
332
+ # and if it doesn't, check if habanalabs driver is loaded
333
+ is_hpu_available = False
334
try:
329
- subprocess.run(["hl-smi"], capture_output=True, check=True)
335
+ out = subprocess.run(["hl-smi"], capture_output=True, check=True)
336
+ is_hpu_available = out.returncode == 0
337
except (FileNotFoundError, PermissionError, subprocess.CalledProcessError):
331
- if not os.path.exists('/dev/accel/accel0') and not os.path.exists(
332
- '/dev/accel/accel_controlD0'):
333
- # last resort...
338
+ if sys.platform.startswith("linux"):
339
try:
340
output = subprocess.check_output(
341
'lsmod | grep habanalabs | wc -l', shell=True)
342
is_hpu_available = int(output) > 0
343
except (ValueError, FileNotFoundError, PermissionError,
344
subprocess.CalledProcessError):
340
- is_hpu_available = False
341
- return is_hpu_available or VLLM_TARGET_DEVICE == "hpu"
345
+ pass
346
+ return is_hpu_available
347
348
349
def _no_device() -> bool: