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)
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)
def get_state(self, link: int) -> EnableState: """Retrieves the state of the device's NvLink for the link specified PASCAL_OR_NEWER""" is_active = EnableState.c_type() fn = self.lib.get_function_pointer("nvmlDeviceGetNvLinkState") ret = fn(self.device.handle, c_uint(link), byref(is_active)) Return.check(ret) return EnableState(is_active.value)
def get_auto_boosted_clocks_enabled( self) -> Tuple[EnableState, EnableState]: """ @return: @rtype: @raise NVMLErrorNotSupported: if hardware doesn't support setting auto boosted clocks """ c_isEnabled = EnableState.c_type() c_defaultIsEnabled = EnableState.c_type() fn = self.lib.get_function_pointer( "nvmlDeviceGetAutoBoostedClocksEnabled") ret = fn(self.handle, byref(c_isEnabled), byref(c_defaultIsEnabled)) Return.check(ret) return EnableState(c_isEnabled.value), EnableState( c_defaultIsEnabled.value)
def query_drain_state(self) -> EnableState: """ Query the drain state of a GPU. This method is used to check if a GPU is in a currently draining state. For Linux only. PASCAL_OR_NEWER, Some Kepler devices supported. @return: The current drain state for this GPU, see EnableState @rtype: EnableState """ from pynvml3.errors import Return from pynvml3.pynvml import NVMLLib current_state = EnableState.c_type() pci_info = self # .nvml_device_get_pci_info() fn = NVMLLib().get_function_pointer("nvmlDeviceQueryDrainState") ret = fn(byref(pci_info), byref(current_state)) Return.check(ret) return EnableState(current_state.value)
def set_auto_boosted_clocks_enabled(self, enabled: EnableState) -> None: """ @param enabled: @type enabled: @return: @rtype: @raise NVMLErrorNotSupported: if hardware doesn't support setting auto boosted clocks """ fn = self.lib.get_function_pointer( "nvmlDeviceSetAutoBoostedClocksEnabled") ret = fn(self.handle, enabled.as_c_type()) Return.check(ret)
def modify_drain_state(self, new_state: EnableState) -> None: """ Modify the drain state of a GPU. This method forces a GPU to no longer accept new incoming requests. Any new NVML process will no longer see this GPU. Persistence mode for this GPU must be turned off before this call is made. Must be called as administrator. For Linux only. PASCAL_OR_NEWER, Some Kepler devices supported. @param new_state: The drain state that should be entered, see EnableState @type new_state: EnableState """ from pynvml3.errors import Return from pynvml3.pynvml import NVMLLib # pci_info = self.nvml_device_get_pci_info() fn = NVMLLib().get_function_pointer("nvmlDeviceModifyDrainState") ret = fn(byref(self), new_state.as_c_type()) Return.check(ret)
def freeze_utilization_counter(self, counter: int, freeze: EnableState) -> None: """ Freeze the NVLINK utilization counters Both the receive and transmit counters are operated on by this function PASCAL_OR_NEWER @param link: Specifies the NvLink link to be queried @type link: int @param counter: Specifies the counter that should be frozen (0 or 1). @type counter: int @param freeze: NVML_FEATURE_ENABLED = freeze the receive and transmit counters NVML_FEATURE_DISABLED = unfreeze the receive and transmit counters @type freeze: EnableState @return: None @rtype: None """ fn = self.lib.get_function_pointer( "nvmlDeviceFreezeNvLinkUtilizationCounter") ret = fn(self.device.handle, c_uint(self.link), c_uint(counter), freeze.as_c_type()) Return.check(ret)
def get_power_management_mode(self) -> EnableState: pcap_mode = EnableState.c_type() fn = self.lib.get_function_pointer("nvmlDeviceGetPowerManagementMode") ret = fn(self.handle, byref(pcap_mode)) Return.check(ret) return EnableState(pcap_mode.value)
def get_persistence_mode(self) -> EnableState: c_state = EnableState.c_type() fn = self.lib.get_function_pointer("nvmlDeviceGetPersistenceMode") ret = fn(self.handle, byref(c_state)) Return.check(ret) return EnableState(c_state.value)
def get_display_active(self) -> EnableState: c_mode = EnableState.c_type() fn = self.lib.get_function_pointer("nvmlDeviceGetDisplayActive") ret = fn(self.handle, byref(c_mode)) Return.check(ret) return EnableState(c_mode.value)
def set_persistence_mode(self, enable_state: EnableState) -> None: fn = self.lib.get_function_pointer("nvmlDeviceSetPersistenceMode") ret = fn(self.handle, enable_state.as_c_type()) Return.check(ret)
def set_ecc_mode(self, mode: EnableState) -> None: fn = self.lib.get_function_pointer("nvmlDeviceSetEccMode") ret = fn(self.handle, mode.as_c_type()) Return.check(ret)
def set_api_restriction(self, api_type: RestrictedAPI, is_restricted: EnableState) -> None: fn = self.lib.get_function_pointer("nvmlDeviceSetAPIRestriction") ret = fn(self.handle, api_type.as_c_type(), is_restricted.as_c_type()) Return.check(ret)
def get_api_restriction(self, api_type: RestrictedAPI) -> EnableState: c_permission = EnableState.c_type() fn = self.lib.get_function_pointer("nvmlDeviceGetAPIRestriction") ret = fn(self.handle, api_type.as_c_type(), byref(c_permission)) Return.check(ret) return EnableState(c_permission.value)
def get_accounting_mode(self) -> EnableState: c_mode = EnableState.c_type() fn = self.lib.get_function_pointer("nvmlDeviceGetAccountingMode") ret = fn(self.handle, byref(c_mode)) Return.check(ret) return EnableState(c_mode.value)