Skip to content

Commit

Permalink
fix intel gpu check (#53)
Browse files Browse the repository at this point in the history
* update assert

* fix gpu filter

* fix utilization negative
  • Loading branch information
CSY-ModelCloud authored Dec 3, 2024
1 parent 112cbef commit 889b624
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion device_smi/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(
):
self.memory_used = memory_used
self.memory_process = memory_process
self.utilization = utilization
self.utilization = max(0.0, utilization)

def __str__(self):
return str(self.__dict__)
Expand Down
10 changes: 6 additions & 4 deletions device_smi/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ def __init__(self, device):
self.device = AppleDevice(self, device_index)
else:
try:
result = _run(["lspci", "|", "grep", "-i", "vga\|3d\|display"])

output = result.lower()
if "intel" in output:
result = _run(["lspci"]).lower().splitlines()
result = "\n".join([
line for line in result
if any(keyword.lower() in line.lower() for keyword in ['vga', '3d', 'display'])
])
if "intel" in result:
self.device = IntelDevice(self, device_index)
else:
self.device = NvidiaDevice(self, device_index)
Expand Down
15 changes: 9 additions & 6 deletions tests/gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
dev = Device("gpu")
print(dev)

assert dev.type == "gpu"
assert dev.pcie
assert dev.gpu
assert dev.type == "gpu", f"wrong type: {dev.type}"
if dev.pcie:
assert dev.pcie.gen
assert dev.pcie.speed
assert dev.pcie.id
if dev.gpu:
assert dev.gpu.driver
assert dev.gpu.firmware
assert dev.model
assert dev.memory_total > 10
assert dev.vendor
assert dev.features
assert dev.memory_total > 10, f"wrong memory size: {dev.memory_total}"

0 comments on commit 889b624

Please sign in to comment.