ibm-cloud-infrastructure - 如何确定裸机设备有 GPU 以及什么类型的 GPU?
问题描述
我正在尝试确定我的 IBM Cloud 帐户中拥有 GPU 的 Bare Metal 设备的数量、GPU 的数量和 GPU 的类型。这如何使用 REST API 来完成?谢谢。
解决方案
尝试使用以下 python 脚本示例:
import SoftLayer
from prettytable import PrettyTable
USERNAME = 'set me'
API_KEY = 'set me'
# Declare the API client
client = SoftLayer.create_client_from_env(USERNAME, API_KEY)
account_service = client['SoftLayer_Account']
x = PrettyTable()
x.field_names = ["HardwareComponentType", "Manufacturer", "Name"]
object_mask = 'mask[components]'
try:
response = account_service.getHardware(mask=object_mask)
count = 0
for hardware in response:
for component in hardware['components']:
component_type = component['hardwareComponentModel']['hardwareGenericComponentModel'][
'hardwareComponentType']['type']
if component_type == 'GPU':
gpu_type = component_type
gpu_manufacturer = component['hardwareComponentModel']['manufacturer']
gpu_name = component['hardwareComponentModel']['name']
x.add_row([gpu_type, gpu_manufacturer, gpu_name])
count = count + 1
print(x)
print("Number of Bare Metal devices in the account that have a GPU")
print(str(count))
except SoftLayer.SoftLayerAPIError as e:
"""
If there was an error returned from the SoftLayer API then bomb out with the
error message.
"""
print("Unable to get the hardware information \nfaultCode= %s, \nfaultString= %s"
% (e.faultCode, e.faultString))
推荐阅读
- openvpn - 如何配置 PAM 身份验证以组合密码 + OTP 令牌
- excel - 将单个工作表的副本发布到 Microsoft Teams
- c - 检测空参数然后使用默认大小写的 C 宏
- c - 如何使用 for 循环在 C 中打印可变大小的“字符串”?
- python - 如何快速炸毁磁盘空间
- java - Java cloudera impala 连接不稳定:使用 [Simba][ImpalaJDBCDriver](500151) 错误设置/关闭会话:{0}
- javascript - 当我尝试在 D3.js 中使用 filter 函数时,它告诉我“data.filter 不是函数”。为什么?
- c++ - 关于 c++ 中的函数 typedef
- ffmpeg - 使用 ffmpeg mpdecimate 中的调试日志删除另一个输入文件的帧
- java - 在错误spring boot rest api期间自定义HTTP响应消息