pynvml_utils
NVML_VALUE_NOT_AVAILABLE_uint = c_uint(-1)
module-attribute
Field Identifiers.
All Identifiers pertain to a device. Each ID is only used once and is guaranteed never to change.
NVMLError
Bases: Exception
Source code in omnigibson/utils/pynvml_utils.py
__new__(typ, value)
Maps value to a proper subclass of NVMLError. See _extractNVMLErrorsAsClasses function for more details
Source code in omnigibson/utils/pynvml_utils.py
_PrintableStructure
Bases: Structure
Abstract class that produces nicer str output than ctypes.Structure. e.g. instead of:
print str(obj)
this class will print class_name(field_name: formatted_value, field_name: formatted_value)
fmt dictionary of
Exact format of returned str from this class is subject to change in the future.
Source code in omnigibson/utils/pynvml_utils.py
_LoadNvmlLibrary()
Load the library if it isn't loaded already
Source code in omnigibson/utils/pynvml_utils.py
_extractNVMLErrorsAsClasses()
Generates a hierarchy of classes on top of NVMLError class.
Each NVML Error gets a new NVMLError subclass. This way try,except blocks can filter appropriate exceptions more easily.
NVMLError is a parent class. Each NVML_ERROR_* gets it's own subclass. e.g. NVML_ERROR_ALREADY_INITIALIZED will be turned into NVMLError_AlreadyInitialized
Source code in omnigibson/utils/pynvml_utils.py
convertStrBytes(func)
In python 3, strings are unicode instead of bytes, and need to be converted for ctypes Args from caller: (1, 'string', <main.c_nvmlDevice_t at 0xFFFFFFFF>) Args passed to function: (1, b'string', <main.c_nvmlDevice_t at 0xFFFFFFFF)>
Returned from function: b'returned string' Returned to caller: 'returned string'