Skip to content

Commit e5a8aee

Browse files
committed
Updated get_available_device_id method
Signed-off-by: Rishin Raj <[email protected]>
1 parent 4c37092 commit e5a8aee

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

QEfficient/utils/device_utils.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,21 @@
66
# -----------------------------------------------------------------------------
77

88
import math
9+
import re
910
import subprocess
1011

1112
from QEfficient.utils.constants import Constants
1213
from QEfficient.utils.logging_utils import logger
1314

1415

16+
def is_networks_loaded(stdout):
17+
# Check is the networks are loaded on the device.
18+
network_loaded = re.search(r"Networks Loaded:(\d+)", stdout)
19+
if network_loaded and int(network_loaded.group(1)) > 0:
20+
return True
21+
return False
22+
23+
1524
def get_available_device_id():
1625
"""
1726
API to check available device id.
@@ -33,7 +42,7 @@ def get_available_device_id():
3342
logger.warning("Not a Cloud AI 100 device, Command not found", command)
3443
return None
3544
if result:
36-
if "Status:Error" in result.stdout:
45+
if "Status:Error" in result.stdout or is_networks_loaded(result.stdout):
3746
device_id += 1
3847
elif "Status:Ready" in result.stdout:
3948
logger.info("device is available.")

0 commit comments

Comments
 (0)