Provides a Python interface to GPU management and monitoring functions.
This is a wrapper around the MXSML library.
Note that this file can be run with 'python -m doctest -v README.txt' although the results are system dependent
pip install .
>>> from pymxsml import *
>>> mxSmlInit()
>>> device_count = mxSmlGetDeviceCount()
>>> for i in range(device_count):
... device_info = mxSmlGetDeviceInfo(i)
... print("Device", i, ":", device_info.deviceName)
...
Device 0 : MXC500Python methods wrap MXSML functions, implemented in a C shared library. Each function's use is the same with the following exceptions:
-
Instead of returning error codes, failing error codes are raised as Python exceptions.
>>> try: ... mxSmlGetDeviceCount() ... except MXSMLError as error: ... print(error) ... Load dynamic library failed
-
C structs are converted into Python classes.
mxSmlReturn_t mxSmlGetMemoryInfo(unsigned int deviceId, mxSmlMemoryInfo_t *memory); typedef struct MxSmlMemoryInfo { long visVramTotal; long visVramUse; long vramTotal; long vramUse; long xttTotal; long xttUse; } mxSmlMemoryInfo_t;
>>> info = mxSmlGetMemoryInfo(0) >>> print "vis_vram use:", info.visVramUse vis_vram use: 7574336 >>> print "vram use:", info.vramUse vram use: 7574336 >>> print "xtt use:", info.xttUse xtt use: 190692
-
Python handles string buffer creation.
mxSmlReturn_t mxSmlGetMacaVersion(char* version, unsigned int* size);
>>> version = mxSmlGetMacaVersion()
-
Get PF device index and info.
>>> device_count = mxSmlGetPfDeviceCount() >>> for i in range(device_count): ... pf_idx = i + 100 ... device_info = mxSmlGetPfDeviceCount(pf_idx) ... print("Device", pf_idx, ":", device_info.deviceName) ... Device 100 : MXC500
For usage information see the MXSML documentation.
All meaningful MXSML constants and enums are exposed in Python.