Example #1
0
    def AddGpu(self, gpuId):
        if self._IsGroupIdStatic():
            raise pydcgm.DcgmException("Can't add a GPU to a static group")

        ret = dcgm_agent.dcgmGroupAddDevice(self._dcgmHandle.handle,
                                            self._groupId, gpuId)
        dcgm_structs._dcgmCheckReturn(ret)
Example #2
0
 def Get(self, statusHandle=None):
     if statusHandle:
         statusHandle = statusHandle.handle
     count = len(self._dcgmGroup.GetGpuIds())
     if count <= 0:
         raise pydcgm.DcgmException("This group has no GPUs, cannot retrieve policies")
     return dcgm_agent.dcgmPolicyGet(self._dcgmHandle.handle, self._groupId, count, statusHandle)
Example #3
0
    def __init__(self,
                 dcgmHandle,
                 groupId=None,
                 groupName=None,
                 groupType=dcgm_structs.DCGM_GROUP_EMPTY):
        self._dcgmHandle = dcgmHandle

        if groupId is None and groupName is None:
            raise pydcgm.DcgmException(
                "Either groupId or groupName is required")

        if groupId is not None:
            self._groupId = groupId
        else:
            self._groupId = dcgm_agent.dcgmGroupCreate(self._dcgmHandle.handle,
                                                       groupType, groupName)

        #Create namespace classes
        self.config = DcgmGroupConfig(self._dcgmHandle, self._groupId, self)
        self.samples = DcgmGroupSamples(self._dcgmHandle, self._groupId, self)
        self.health = DcgmGroupHealth(self._dcgmHandle, self._groupId, self)
        self.policy = DcgmGroupPolicy(self._dcgmHandle, self._groupId, self)
        self.discovery = DcgmGroupDiscovery(self._dcgmHandle, self._groupId,
                                            self)
        self.stats = DcgmGroupStats(self._dcgmHandle, self._groupId, self)
        self.action = DcgmGroupAction(self._dcgmHandle, self._groupId, self)
        self.profiling = DcgmGroupProfiling(self._dcgmHandle, self._groupId,
                                            self)
Example #4
0
 def Register(self, condition, beginCallback=None, finishCallback=None):
     if beginCallback is None and finishCallback is None:
         raise pydcgm.DcgmException(
             "At least 1 callback must be provided to register that is not None"
         )
     dcgm_agent.dcgmPolicyRegister(self._dcgmHandle.handle, self._groupId,
                                   condition, beginCallback, finishCallback)
Example #5
0
    def RemoveGpu(self, gpuId):
        if self._IsGroupIdStatic():
            raise pydcgm.DcgmException(
                "Can't remove a GPU from a static group")

        ret = dcgm_agent.dcgmGroupRemoveDevice(self._dcgmHandle.handle,
                                               self._groupId, gpuId)
        dcgm_structs._dcgmCheckReturn(ret)
Example #6
0
    def AddEntity(self, entityGroupId, entityId):
        if self._IsGroupIdStatic():
            raise pydcgm.DcgmException("Can't add an entity to a static group")

        ret = dcgm_agent.dcgmGroupAddEntity(self._dcgmHandle.handle,
                                            self._groupId, entityGroupId,
                                            entityId)
        dcgm_structs._dcgmCheckReturn(ret)
Example #7
0
    def RemoveEntity(self, entityGroupId, entityId):
        if self._IsGroupIdStatic():
            raise pydcgm.DcgmException(
                "Can't remove an entity from a static group")

        ret = dcgm_agent.dcgmGroupRemoveEntity(self._dcgmHandle.handle,
                                               self._groupId, entityGroupId,
                                               entityId)
        dcgm_structs._dcgmCheckReturn(ret)