Пример #1
0
    def get_retired_pages(self,
                          source_filter: PageRetirementCause) -> List[int]:
        c_source = source_filter.as_c_type()
        c_count = c_uint(0)
        fn = self.lib.get_function_pointer("nvmlDeviceGetRetiredPages")

        # First call will get the size
        ret = fn(self.handle, c_source, byref(c_count), None)
        result = Return(ret)

        Return.check(ret)

        # # this should only fail with insufficient size
        # if ((result != Return.SUCCESS) and
        #         (result != Return.ERROR_INSUFFICIENT_SIZE)):
        #     raise NVMLError(ret)

        # call again with a buffer
        # oversize the array for the rare cases where additional pages
        # are retired between NVML calls
        c_count.value = c_count.value * 2 + 5
        page_array = c_ulonglong * c_count.value
        c_pages = page_array()
        ret = fn(self.handle, c_source, byref(c_count), c_pages)
        Return.check(ret)
        return list(c_pages)
Пример #2
0
    def get_supported_graphics_clocks(self,
                                      memory_clock_mhz: int) -> List[int]:
        # first call to get the size
        c_count = c_uint(0)
        fn = self.lib.get_function_pointer(
            "nvmlDeviceGetSupportedGraphicsClocks")
        ret = fn(self.handle, c_uint(memory_clock_mhz), byref(c_count), None)
        result = Return(ret)

        if result == Return.SUCCESS:
            # special case, no clocks
            return []
        elif result == Return.ERROR_INSUFFICIENT_SIZE:
            # typical case
            clocks_array = c_uint * c_count.value
            c_clocks = clocks_array()

            # make the call again
            ret = fn(self.handle, c_uint(memory_clock_mhz), byref(c_count),
                     c_clocks)
            Return.check(ret)
            return list(c_clocks)
        else:
            # error case
            raise NVMLError(ret)
Пример #3
0
    def get_hic_version(self) -> List[HwbcEntry]:
        """Retrieves the IDs and firmware versions for any Host Interface Cards (HICs) in the system.
        S_CLASS
        The hwbcCount argument is expected to be set to the size of the input hwbcEntries array.
        The HIC must be connected to an S-class system for it to be reported by this function."""
        c_count = c_uint(0)
        hics = None
        fn = self.lib.get_function_pointer("nvmlSystemGetHicVersion")

        # get the count
        ret = fn(byref(c_count), None)

        # this should only fail with insufficient size
        return_value = Return(ret)
        if return_value != Return.SUCCESS and return_value != Return.ERROR_INSUFFICIENT_SIZE:
            raise return_value.get_exception()

        # if there are no hics
        if c_count.value == 0:
            return []

        hic_array = HwbcEntry * c_count.value
        hics = hic_array()
        ret = fn(byref(c_count), hics)
        Return.check(ret)
        return list(hics)
Пример #4
0
    def _get_running_processes(self, fn) -> List[ProcessInfo]:
        """

        Note:
            On Windows with the WDDM driver, usedGpuMemory is reported as None
            Code that processes this structure should check for None, I.E.::

                if (info.usedGpuMemory == None):
                    # handle the error
                    pass

            See NVML documentation for more information
        Args:
            fn ():

        Returns:

        """
        # first call to get the size
        c_count = c_uint(0)
        ret = fn(self.handle, byref(c_count), None)
        result = Return(ret)

        if result == Return.SUCCESS:
            # special case, no running processes
            return []
        elif result == Return.ERROR_INSUFFICIENT_SIZE:
            # typical case
            # oversize the array incase more processes are created
            c_count.value = c_count.value * 2 + 5
            proc_array = ProcessInfo * c_count.value
            c_procs = proc_array()

            # make the call again
            ret = fn(self.handle, byref(c_count), c_procs)
            Return.check(ret)

            procs = []
            for i in range(c_count.value):
                # use an alternative struct for this object
                obj: ProcessInfo = c_procs[i].get_friendly_object()
                if obj.usedGpuMemory == VALUE_NOT_AVAILABLE_ulonglong:
                    # special case for WDDM on Windows, see comment above
                    obj.usedGpuMemory = None
                procs.append(obj)
            return procs
        else:
            # error case
            raise NVMLError(ret)