-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,38 @@ | ||
import subprocess | ||
import re | ||
|
||
def get_devices(): | ||
result = subprocess.run(["wmic", "path", "win32_VideoController", "get", "name,pnpdeviceid"], capture_output=True, text=True) | ||
lines = result.stdout.split("\n") | ||
devices = {} # {name: device_id} | ||
for line in lines: | ||
# vendor:8086 is an Intel device | ||
if "VEN_8086" in line: | ||
parts = line.split(" ") | ||
name = parts[0].strip() | ||
for part in parts[1:]: | ||
if "VEN_8086" in part: | ||
# regex match "VEN_8086&DEV_{device_id}" | ||
if match := re.search(r"VEN_8086\&DEV_([0-9A-F]+)", part): | ||
device_id = match.group(1) | ||
devices[name] = device_id | ||
break | ||
|
||
return devices | ||
|
||
devices = get_devices() | ||
|
||
def is_supported(name): | ||
return "arc" in name.lower() or (name in devices and devices[name].lower() == "e20b") | ||
|
||
import torch | ||
import intel_extension_for_pytorch as ipex # noqa: F401 | ||
|
||
# filter out non-Arc devices | ||
# filter out unsupported devices | ||
supported_ids = [] | ||
for i in range(torch.xpu.device_count()): | ||
props = torch.xpu.get_device_properties(i) | ||
if "arc" in props.name.lower(): | ||
if is_supported(props.name): | ||
supported_ids.append(str(i)) | ||
|
||
print(",".join(supported_ids)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters