コード例 #1
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_temperature_threshold(self,
                               threshold: TemperatureThresholds) -> int:
     c_temp = c_uint()
     fn = self.lib.get_function_pointer("nvmlDeviceGetTemperatureThreshold")
     ret = fn(self.handle, threshold.as_c_type(), byref(c_temp))
     Return.check(ret)
     return c_temp.value
コード例 #2
0
ファイル: structs.py プロジェクト: sirexeclp/nvidia-ml-py3
    def remove_gpu(self,
                   gpu_state=DetachGpuState.REMOVE,
                   link_state=PcieLinkState.KEEP):
        """
        This method will remove the specified GPU from the view of both NVML and the NVIDIA kernel driver
        as long as no other processes are attached. If other processes are attached,
        this call will return NVML_ERROR_IN_USE and the GPU will be returned to its original "draining" state.
        Note: the only situation where a process can still be attached after nvmlDeviceModifyDrainState()
        is called to initiate the draining state is if that process was using, and is still using,
        a GPU before the call was made. Also note, persistence mode counts as an attachment to the GPU
        thus it must be disabled prior to this call.
        For long-running NVML processes please note that this will change the enumeration of current GPUs.
        For example, if there are four GPUs present and GPU1 is removed, the new enumeration will be 0-2.
        Also, device handles after the removed GPU will not be valid and must be re-established.
        Must be run as administrator. For Linux only.

        PASCAL_OR_NEWER, Some Kepler devices supported.
        """
        from pynvml3.errors import Return
        from pynvml3.pynvml import NVMLLib
        # if self.get_persistence_mode() == EnableState.FEATURE_ENABLED:
        #     self.set_persistence_mode(EnableState.FEATURE_DISABLED)
        pci_info = self  # .nvml_device_get_pci_info()
        fn = NVMLLib().get_function_pointer("nvmlDeviceRemoveGpu")
        ret = fn(byref(pci_info), gpu_state.as_c_type(),
                 link_state.as_c_type())
        Return.check(ret)
コード例 #3
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_retired_pages_pending_status(self) -> EnableState:
     c_pending = EnableState.c_type()
     fn = self.lib.get_function_pointer(
         "nvmlDeviceGetRetiredPagesPendingStatus")
     ret = fn(self.handle, byref(c_pending))
     Return.check(ret)
     return EnableState(c_pending.value)
コード例 #4
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
    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)
コード例 #5
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_accounting_pids(self) -> List[int]:
     count = c_uint(self.get_accounting_buffer_size())
     pids = (c_uint * count.value)()
     fn = self.lib.get_function_pointer("nvmlDeviceGetAccountingPids")
     ret = fn(self.handle, byref(count), pids)
     Return.check(ret)
     return list(pids)
コード例 #6
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_max_pcie_link_generation(self) -> int:
     fn = self.lib.get_function_pointer(
         "nvmlDeviceGetMaxPcieLinkGeneration")
     gen = c_uint()
     ret = fn(self.handle, byref(gen))
     Return.check(ret)
     return gen.value
コード例 #7
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def register_events(self, event_types: EventType) -> "EventSet":
     """
     Starts recording of events on a specified devices and add the events to specified nvmlEventSet_t
     FERMI_OR_NEWER
     Ecc events are available only on ECC enabled devices (see nvmlDeviceGetTotalEccErrors)
     Power capping events are available only on Power Management enabled devices
     (see nvmlDeviceGetPowerManagementMode)
     For Linux only.
     IMPORTANT: Operations on set are not thread safe
     This call starts recording of events on specific device.
     All events that occurred before this call are not recorded.
     Checking if some event occurred can be done with nvmlEventSetWait.
     If function reports NVML_ERROR_UNKNOWN, event set is in undefined state and should be freed.
     If function reports NVML_ERROR_NOT_SUPPORTED, event set can still be used.
     None of the requested eventTypes are registered in that case.
     @param event_types:
     @type event_types:
     @param event_set:
     @type event_set: EventSet
     @return:
     @rtype:
     """
     fn = self.lib.get_function_pointer("nvmlDeviceRegisterEvents")
     event_set = EventSet()
     ret = fn(self.handle, event_types.as_c_type(), event_set.handle)
     Return.check(ret)
     return event_set
コード例 #8
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_inforom_image_version(self) -> str:
     c_version = create_string_buffer(Device.INFOROM_VERSION_BUFFER_SIZE)
     fn = self.lib.get_function_pointer("nvmlDeviceGetInforomImageVersion")
     ret = fn(self.handle, c_version,
              c_uint(Device.INFOROM_VERSION_BUFFER_SIZE))
     Return.check(ret)
     return c_version.value.decode("UTF-8")
コード例 #9
0
ファイル: system.py プロジェクト: sirexeclp/nvidia-ml-py3
    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)
コード例 #10
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_vbios_version(self) -> str:
     c_version = create_string_buffer(Device.VBIOS_VERSION_BUFFER_SIZE)
     fn = self.lib.get_function_pointer("nvmlDeviceGetVbiosVersion")
     ret = fn(self.handle, c_version,
              c_uint(Device.VBIOS_VERSION_BUFFER_SIZE))
     Return.check(ret)
     return c_version.value.decode("UTF-8")
コード例 #11
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_current_clocks_throttle_reasons(self) -> int:
     c_reasons = c_ulonglong()
     fn = self.lib.get_function_pointer(
         "nvmlDeviceGetCurrentClocksThrottleReasons")
     ret = fn(self.handle, byref(c_reasons))
     Return.check(ret)
     return c_reasons.value
コード例 #12
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_power_management_default_limit(self) -> int:
     c_limit = c_uint()
     fn = self.lib.get_function_pointer(
         "nvmlDeviceGetPowerManagementDefaultLimit")
     ret = fn(self.handle, byref(c_limit))
     Return.check(ret)
     return c_limit.value
コード例 #13
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_fan_speed(self) -> int:
     c_speed = c_uint()
     fn = self.lib.get_function_pointer("nvmlDeviceGetFanSpeed_v2")
     fan = c_uint(0)
     ret = fn(self.handle, fan, byref(c_speed))
     Return.check(ret)
     return c_speed.value
コード例 #14
0
ファイル: system.py プロジェクト: sirexeclp/nvidia-ml-py3
 def _get_cuda_driver_version(self) -> int:
     """Retrieves the version of the CUDA driver from the shared library."""
     fn = self.lib.get_function_pointer("nvmlSystemGetCudaDriverVersion_v2")
     cuda_driver_version = c_int()
     ret = fn(byref(cuda_driver_version))
     Return.check(ret)
     return cuda_driver_version.value
コード例 #15
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
    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)
コード例 #16
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_inforom_configuration_checksum(self) -> int:
     c_checksum = c_uint()
     fn = self.lib.get_function_pointer(
         "nvmlDeviceGetInforomConfigurationChecksum")
     ret = fn(self.handle, byref(c_checksum))
     Return.check(ret)
     return c_checksum.value
コード例 #17
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_decoder_utilization(self) -> Tuple[int, int]:
     c_util = c_uint()
     c_samplingPeriod = c_uint()
     fn = self.lib.get_function_pointer("nvmlDeviceGetDecoderUtilization")
     ret = fn(self.handle, byref(c_util), byref(c_samplingPeriod))
     Return.check(ret)
     return c_util.value, c_samplingPeriod.value
コード例 #18
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_inforom_version(self, info_rom_object: InfoRom) -> str:
     c_version = create_string_buffer(Device.INFOROM_VERSION_BUFFER_SIZE)
     fn = self.lib.get_function_pointer("nvmlDeviceGetInforomVersion")
     ret = fn(self.handle, InfoRom.c_type(info_rom_object.value), c_version,
              c_uint(Device.INFOROM_VERSION_BUFFER_SIZE))
     Return.check(ret)
     return c_version.value.decode("UTF-8")
コード例 #19
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_total_ecc_errors(self, error_type: MemoryErrorType,
                          counter_type: EccCounterType) -> int:
     c_count = c_ulonglong()
     fn = self.lib.get_function_pointer("nvmlDeviceGetTotalEccErrors")
     ret = fn(self.handle, error_type.as_c_type(), counter_type.as_c_type(),
              byref(c_count))
     Return.check(ret)
     return c_count.value
コード例 #20
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_ecc_mode(self) -> Tuple[EnableState, EnableState]:
     c_currState = EnableState.c_type()
     c_pendingState = EnableState.c_type()
     fn = self.lib.get_function_pointer("nvmlDeviceGetEccMode")
     ret = fn(self.handle, byref(c_currState), byref(c_pendingState))
     Return.check(ret)
     return EnableState(c_currState.value), EnableState(
         c_pendingState.value)
コード例 #21
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_cpu_affinity(self) -> List[int]:
     cpu_set_size = math.ceil(os.cpu_count() / sizeof(c_ulong))
     affinity_array = c_ulong * cpu_set_size
     c_affinity = affinity_array()
     fn = self.lib.get_function_pointer("nvmlDeviceGetCpuAffinity")
     ret = fn(self.handle, c_uint(cpu_set_size), byref(c_affinity))
     Return.check(ret)
     return list(c_affinity)
コード例 #22
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_power_management_limit_constraints(self) -> Tuple[int, int]:
     c_minLimit = c_uint()
     c_maxLimit = c_uint()
     fn = self.lib.get_function_pointer(
         "nvmlDeviceGetPowerManagementLimitConstraints")
     ret = fn(self.handle, byref(c_minLimit), byref(c_maxLimit))
     Return.check(ret)
     return c_minLimit.value, c_maxLimit.value
コード例 #23
0
 def set_utilization_control(self, link: int, counter: int,
                             control: NvLinkUtilizationControl,
                             reset: bool) -> None:
     fn = self.lib.get_function_pointer(
         "nvmlDeviceSetNvLinkUtilizationControl")
     ret = fn(self.device.handle, c_uint(link), c_uint(counter),
              byref(control), c_uint(reset))
     Return.check(ret)
コード例 #24
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_max_customer_boost_clock(self, clock_type: ClockType) -> int:
     """Retrieves the customer defined maximum boost clock speed specified by the given clock type."""
     fn = self.lib.get_function_pointer(
         "nvmlDeviceGetMaxCustomerBoostClock")
     clock_mhz = c_uint()
     ret = fn(self.handle, clock_type.as_c_type(), byref(clock_mhz))
     Return.check(ret)
     return clock_mhz.value
コード例 #25
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_driver_model(self) -> Tuple[DriverModel, DriverModel]:
     c_currModel = DriverModel.c_type()
     c_pendingModel = DriverModel.c_type()
     fn = self.lib.get_function_pointer("nvmlDeviceGetDriverModel")
     ret = fn(self.handle, byref(c_currModel), byref(c_pendingModel))
     Return.check(ret)
     return DriverModel(c_currModel.value), DriverModel(
         c_pendingModel.value)
コード例 #26
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_accounting_stats(self, pid: int) -> AccountingStats:
     stats = AccountingStats()
     fn = self.lib.get_function_pointer("nvmlDeviceGetAccountingStats")
     ret = fn(self.handle, c_uint(pid), byref(stats))
     Return.check(ret)
     if stats.maxMemoryUsage == VALUE_NOT_AVAILABLE_ulonglong:
         # special case for WDDM on Windows, see comment above
         stats.maxMemoryUsage = None
     return stats
コード例 #27
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_supported_event_types(self) -> EventType:
     """Returns information about events supported on device
     FERMI_OR_NEWER
     Events are not supported on Windows. So this function returns an empty mask in eventTypes on Windows."""
     c_eventTypes = c_ulonglong()
     fn = self.lib.get_function_pointer("nvmlDeviceGetSupportedEventTypes")
     ret = fn(self.handle, byref(c_eventTypes))
     Return.check(ret)
     return EventType(c_eventTypes.value)
コード例 #28
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
    def get_violation_status(
            self, perf_policy_type: PerfPolicyType) -> ViolationTime:
        c_violTime = ViolationTime()
        fn = self.lib.get_function_pointer("nvmlDeviceGetViolationStatus")

        # Invoke the method to get violation time
        ret = fn(self.handle, perf_policy_type.as_c_type(), byref(c_violTime))
        Return.check(ret)
        return c_violTime
コード例 #29
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_gpu_operation_mode(
         self) -> Tuple[GpuOperationMode, GpuOperationMode]:
     c_currState = GpuOperationMode.c_type()
     c_pendingState = GpuOperationMode.c_type()
     fn = self.lib.get_function_pointer("nvmlDeviceGetGpuOperationMode")
     ret = fn(self.handle, byref(c_currState), byref(c_pendingState))
     Return.check(ret)
     return GpuOperationMode(c_currState.value), GpuOperationMode(
         c_pendingState.value)
コード例 #30
0
ファイル: device.py プロジェクト: sirexeclp/nvidia-ml-py3
 def get_memory_error_counter(self, error_type: MemoryErrorType,
                              counter_type: EccCounterType,
                              location_type: MemoryLocation) -> int:
     c_count = c_ulonglong()
     fn = self.lib.get_function_pointer("nvmlDeviceGetMemoryErrorCounter")
     ret = fn(self.handle, error_type.as_c_type(), counter_type.as_c_type(),
              location_type.as_c_type(), byref(c_count))
     Return.check(ret)
     return c_count.value