5. Pymxsml使用说明
5.1. 简介
Pymxsml是基于MXSML封装的一套Python API程序开发库。使用这套开发库,可以方便地对沐曦GPU设备进行状态查询和管理。
5.2. 安装
操作步骤
5.3. 编程指南
用Python语言导入Pymxsml模块读取所有卡的信息,示例如下:
from pymxsml import *
# 调用任何Pymxsml API前都需要先调用mxSmlInit完成初始化
# 接口调用失败,会产生对应的python异常
mxSmlInit()
# 获取可用设备总数,设备ID从0开始依次编号:0,1,2…deviceNum-1
device_num = mxSmlGetDeviceCount()
for i in range(device_num):
device_info = mxSmlGetDeviceInfo(i)
print("device id", i, ", bdf id:", device_info.bdfId, ", type:", device_info.deviceName)
运行example:
python3 example.py