MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / list_gpus

Method list_gpus

vmm/src/vmm-cli.py:1224–1249  ·  view source on GitHub ↗

List all available GPUs.

(self, json_output: bool = False)

Source from the content-addressed store, hash-verified

1222 )
1223
1224 def list_gpus(self, json_output: bool = False) -> None:
1225 """List all available GPUs."""
1226 response = self.rpc_call("ListGpus")
1227 gpus = response.get("gpus", [])
1228
1229 if json_output:
1230 # Return raw JSON data for automation/testing
1231 print(json.dumps(gpus, indent=2))
1232 return
1233
1234 if not gpus:
1235 print("No GPUs found")
1236 return
1237
1238 headers = ["Slot", "Product ID", "Description", "Available"]
1239 rows = []
1240 for gpu in gpus:
1241 row = [
1242 gpu.get("slot", "-"),
1243 gpu.get("product_id", "-"),
1244 gpu.get("description", "-"),
1245 "Yes" if gpu.get("is_free", False) else "No",
1246 ]
1247 rows.append(row)
1248
1249 print(format_table(rows, headers))
1250
1251
1252def format_table(rows, headers):

Callers 1

mainFunction · 0.95

Calls 4

rpc_callMethod · 0.95
format_tableFunction · 0.85
appendMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected