Skip to content

Commit

Permalink
[HPU][Bugfix] Don't use /dev/accel/accel0 for HPU autodetection in se…
Browse files Browse the repository at this point in the history
…tup.py (vllm-project#12046)

Signed-off-by: Konrad Zawora <kzawora@habana.ai>
  • Loading branch information
kzawora-intel authored Jan 15, 2025
1 parent 42f5e7c commit 1a51b9f
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,21 +324,26 @@ def run(self) -> None:


def _is_hpu() -> bool:
is_hpu_available = True
# if VLLM_TARGET_DEVICE env var was set explicitly, skip HPU autodetection
if os.getenv("VLLM_TARGET_DEVICE", None) == VLLM_TARGET_DEVICE:
return VLLM_TARGET_DEVICE == "hpu"

# if VLLM_TARGET_DEVICE was not set explicitly, check if hl-smi succeeds,
# and if it doesn't, check if habanalabs driver is loaded
is_hpu_available = False
try:
subprocess.run(["hl-smi"], capture_output=True, check=True)
out = subprocess.run(["hl-smi"], capture_output=True, check=True)
is_hpu_available = out.returncode == 0
except (FileNotFoundError, PermissionError, subprocess.CalledProcessError):
if not os.path.exists('/dev/accel/accel0') and not os.path.exists(
'/dev/accel/accel_controlD0'):
# last resort...
if sys.platform.startswith("linux"):
try:
output = subprocess.check_output(
'lsmod | grep habanalabs | wc -l', shell=True)
is_hpu_available = int(output) > 0
except (ValueError, FileNotFoundError, PermissionError,
subprocess.CalledProcessError):
is_hpu_available = False
return is_hpu_available or VLLM_TARGET_DEVICE == "hpu"
pass
return is_hpu_available


def _no_device() -> bool:
Expand Down

0 comments on commit 1a51b9f

Please # to comment.