Skip to content

Commit af117b9

Browse files
authored
Solve GPU list display issues (#316)
* Fix: Solved error messages showing the CRN list for GPUs and also added the GPU sort and filter. * Fix: Solved code quality issues. * Fix: Solve GPU issue on allocation
1 parent 714ad31 commit af117b9

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/aleph_client/commands/instance/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,10 @@ async def create(
385385
raise typer.Exit(1)
386386
if gpu:
387387
if crn.machine_usage and crn.machine_usage.gpu:
388+
if len(crn.machine_usage.gpu.available_devices) < 1:
389+
echo("Selected CRN does not have any GPUs available.")
390+
raise typer.Exit(1)
391+
388392
echo("Select GPU to use:")
389393
table = Table(box=box.SIMPLE_HEAVY)
390394
table.add_column("Number", style="white", overflow="fold")
@@ -457,7 +461,7 @@ async def create(
457461

458462
# Instances that need to be started by notifying a specific CRN
459463
crn_url = crn.url if crn and crn.url else None
460-
if crn and (is_stream or confidential):
464+
if crn and (is_stream or confidential or gpu):
461465
if not crn_url:
462466
# Not the ideal solution
463467
logger.debug(f"Cannot allocate {item_hash}: no CRN url")

src/aleph_client/commands/instance/display.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@ class CRNTable(App[CRNInfo]):
3131
only_reward_address: bool = False
3232
only_qemu: bool = False
3333
only_confidentials: bool = False
34+
only_gpu: bool = False
3435
current_sorts: set = set()
3536
BINDINGS = [
3637
("s", "sort_by_score", "Sort By Score"),
3738
("n", "sort_by_name", "Sort By Name"),
3839
("v", "sort_by_version", "Sort By Version"),
3940
("a", "sort_by_address", "Sort By Address"),
4041
("c", "sort_by_confidential", "Sort By 🔒 Confidential"),
41-
("q", "sort_by_qemu", "Sort By Qemu"),
42+
## ("q", "sort_by_qemu", "Sort By Qemu"),
43+
("g", "sort_by_gpu", "Sort By GPU"),
4244
("u", "sort_by_url", "Sort By URL"),
4345
("x", "quit", "Exit"),
4446
]
@@ -128,6 +130,7 @@ async def fetch_node_info(self, node: CRNInfo):
128130
)
129131
node.qemu_support = crn_info.get("computing", {}).get("ENABLE_QEMU_SUPPORT", False)
130132
node.confidential_computing = crn_info.get("computing", {}).get("ENABLE_CONFIDENTIAL_COMPUTING", False)
133+
node.gpu_support = crn_info.get("computing", {}).get("ENABLE_GPU_SUPPORT", False)
131134
node.machine_usage = crn_info.get("machine_usage")
132135

133136
# Skip nodes without machine usage
@@ -149,7 +152,11 @@ async def fetch_node_info(self, node: CRNInfo):
149152
logger.debug(f"Skipping node {node.hash}, no confidential support")
150153
return
151154
# Skip non-gpu nodes if only-gpu is set
152-
if self.only_gpu and not node.gpu_support and len(node.machine_usage.gpu.available_devices) < 1:
155+
if (
156+
self.only_gpu
157+
and not node.gpu_support
158+
and not (node.machine_usage.gpu and len(node.machine_usage.gpu.available_devices) < 1)
159+
):
153160
logger.debug(f"Skipping node {node.hash}, no GPU support or without GPU available")
154161
return
155162
self.filtered_crns += 1
@@ -220,5 +227,8 @@ def action_sort_by_confidential(self):
220227
def action_sort_by_qemu(self):
221228
self.sort_by("qemu_support")
222229

230+
def action_sort_by_gpu(self):
231+
self.sort_by("gpu_support")
232+
223233
def action_sort_by_url(self):
224234
self.sort_by("url")

0 commit comments

Comments
 (0)