# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/system/_device.pyx

from __future__ import annotations

from typing import Iterable

import cuda.core
from cuda.bindings import nvml
from cuda.core.system.typing import (AddressingMode, AffinityScope, ClockId,
                                     ClocksEventReasons, ClockType,
                                     CoolerControl, CoolerTarget, DeviceArch,
                                     EventType, FanControlPolicy, FieldId,
                                     GpuP2PCapsIndex, GpuP2PStatus,
                                     GpuTopologyLevel, InforomObject,
                                     TemperatureThresholds, ThermalController,
                                     ThermalTarget)


class ClockOffsets:
    """
    Contains clock offset information.
    """

    def __init__(self, clock_offset: nvml.ClockOffset):
        ...

    @property
    def clock_offset_mhz(self) -> int:
        """
        The current clock offset in MHz.
        """

    @property
    def max_offset_mhz(self) -> int:
        """
        The maximum clock offset in MHz.
        """

    @property
    def min_offset_mhz(self) -> int:
        """
        The minimum clock offset in MHz.
        """

class ClockInfo:
    """
    Accesses various clock information about a device.
    """

    def __init__(self, handle: int, clock_type: ClockType | str):
        ...

    def get_current_mhz(self, clock_id: ClockId | str=...) -> int:
        """
        Get the current clock speed of a specific clock domain, in MHz.

        For Kepler™ or newer fully supported devices.

        Parameters
        ----------
        clock_id: :class:`ClockId` | str
            The clock ID to query.  Defaults to the current clock value.

        Returns
        -------
        int
            The clock speed in MHz.
        """

    def get_max_mhz(self) -> int:
        """
        Get the maximum clock speed of a specific clock domain, in MHz.

        For Fermi™ or newer fully supported devices.

        Current P0 clocks (reported by :meth:`get_current_mhz` can differ from
        max clocks by a few MHz.

        Returns
        -------
        int
            The maximum clock speed in MHz.
        """

    def get_max_customer_boost_mhz(self) -> int:
        """
        Get the maximum customer boost clock speed of a specific clock, in MHz.

        For Pascal™ or newer fully supported devices.

        Returns
        -------
        int
            The maximum customer boost clock speed in MHz.
        """

    def get_min_max_clock_of_pstate_mhz(self, pstate: int) -> tuple[int, int]:
        """
        Get the minimum and maximum clock speeds for this clock domain
        at a given performance state (Pstate), in MHz.

        Parameters
        ----------
        pstate: int
            The performance state to query.  Must be an int between 0 and 15,
            where 0 is the highest performance state (P0) and 15 is the lowest
            (P15).

        Returns
        -------
        tuple[int, int]
            A tuple containing the minimum and maximum clock speeds in MHz.
        """

    def get_offsets(self, pstate: int) -> ClockOffsets:
        """
        Retrieve min, max and current clock offset of some clock domain for a given Pstate.

        For Maxwell™ or newer fully supported devices.

        Parameters
        ----------
        pstate: int
            The performance state to query.  Must be an int between 0 and 15,
            where 0 is the highest performance state (P0) and 15 is the lowest
            (P15).

        Returns
        -------
        :obj:`~_device.ClockOffsets`
            An object with the min, max and current clock offset.
        """

class CoolerInfo:

    def __init__(self, cooler_info: nvml.CoolerInfo):
        ...

    @property
    def signal_type(self) -> CoolerControl | None:
        """
        The cooler's control signal characteristics.

        The possible types are variable and toggle.
        """

    @property
    def target(self) -> list[CoolerTarget]:
        """
        The target that cooler controls.

        Targets may be GPU, Memory, Power Supply, or all of these.  See
        :class:`CoolerTarget` for details.
        """

class DeviceAttributes:
    """
    Various device attributes.
    """

    def __init__(self, attributes: nvml.DeviceAttributes):
        ...

    @property
    def multiprocessor_count(self) -> int:
        """
        The streaming multiprocessor count
        """

    @property
    def shared_copy_engine_count(self) -> int:
        """
        The shared copy engine count
        """

    @property
    def shared_decoder_count(self) -> int:
        """
        The shared decoder engine count
        """

    @property
    def shared_encoder_count(self) -> int:
        """
        The shared encoder engine count
        """

    @property
    def shared_jpeg_count(self) -> int:
        """
        The shared JPEG engine count
        """

    @property
    def shared_ofa_count(self) -> int:
        """
        The shared optical flow accelerator (OFA) engine count
        """

    @property
    def gpu_instance_slice_count(self) -> int:
        """
        The GPU instance slice count
        """

    @property
    def compute_instance_slice_count(self) -> int:
        """
        The compute instance slice count
        """

    @property
    def memory_size_mb(self) -> int:
        """
        Device memory size in MiB
        """

class EventData:
    """
    Data about a single event.
    """

    def __init__(self, event_data: nvml.EventData):
        ...

    @property
    def device(self) -> Device:
        """
        The device on which the event occurred.
        """

    @property
    def event_type(self) -> EventType:
        """
        The type of event that was triggered.
        """

    @property
    def event_data(self) -> int:
        """
        Returns Xid error for the device in the event of
        :attr:`~cuda.core.system.EventType.XID_CRITICAL_ERROR`.

        Raises :class:`ValueError` for other event types.
        """

    @property
    def gpu_instance_id(self) -> int:
        """
        The GPU instance ID for MIG devices.

        Only valid for events of type :attr:`EventType.XID_CRITICAL_ERROR`.

        Raises :class:`ValueError` for other event types.
        """

    @property
    def compute_instance_id(self) -> int:
        """
        The Compute instance ID for MIG devices.

        Only valid for events of type :attr:`EventType.XID_CRITICAL_ERROR`.

        Raises :class:`ValueError` for other event types.
        """

class DeviceEvents:
    """
    Represents a set of events that can be waited on for a specific device.
    """

    def __init__(self, device_handle: int, events: EventType | str | list[EventType | str]):
        ...

    def __dealloc__(self) -> None:
        ...

    def wait(self, timeout_ms: int=0) -> EventData:
        """
        Wait for events in the event set.

        For Fermi™ or newer fully supported devices.

        If some events are ready to be delivered at the time of the call,
        function returns immediately.  If there are no events ready to be
        delivered, function sleeps until event arrives but not longer than
        specified timeout. If timeout passes, a
        :class:`cuda.core.system.TimeoutError` is raised. This function in
        certain conditions can return before specified timeout passes (e.g. when
        interrupt arrives).

        On Windows, in case of Xid error, the function returns the most recent
        Xid error type seen by the system.  If there are multiple Xid errors
        generated before ``wait`` is invoked, then the last seen Xid
        error type is returned for all Xid error events.

        On Linux, every Xid error event would return the associated event data
        and other information if applicable.

        In MIG mode, if device handle is provided, the API reports all the
        events for the available instances, only if the caller has appropriate
        privileges. In absence of required privileges, only the events which
        affect all the instances (i.e. whole device) are reported.

        This API does not currently support per-instance event reporting using
        MIG device handles.

        Parameters
        ----------
        timeout_ms: int
            The timeout in milliseconds. A value of 0 means to wait indefinitely.

        Raises
        ------
        :class:`cuda.core.system.TimeoutError`
            If the timeout expires before an event is received.
        :class:`cuda.core.system.GpuIsLostError`
            If the GPU has fallen off the bus or is otherwise inaccessible.
        """

class FanInfo:
    """
    Manages information related to a specific fan on a specific device.
    """

    def __init__(self, handle: int, fan: int):
        ...

    @property
    def speed(self) -> int:
        """
        Get/set the intended operating speed of the device's fan.

        For all discrete products with dedicated fans.

        Note: The reported speed is the intended fan speed.  If the fan is
        physically blocked and unable to spin, the output will not match the
        actual fan speed.

        The fan speed is expressed as a percentage of the product's maximum
        noise tolerance fan speed.  This value may exceed 100% in certain cases.
        """

    @speed.setter
    def speed(self, speed: int) -> None:
        ...

    @property
    def speed_rpm(self) -> int:
        """
        The intended operating speed of the device's fan in rotations per minute
        (RPM).

        For Maxwell™ or newer fully supported devices.

        For all discrete products with dedicated fans.

        Note: The reported speed is the intended fan speed.  If the fan is
        physically blocked and unable to spin, the output will not match the
        actual fan speed.
        """

    @property
    def target_speed(self) -> int:
        """
        Retrieves the intended target speed of the device's specified fan.

        For all discrete products with dedicated fans.

        Normally, the driver dynamically adjusts the fan based on
        the needs of the GPU. But when users set fan speed using ``speed``,
        the driver will attempt to make the fan achieve that setting.
        The actual current speed of the fan is reported in ``speed``.

        The fan speed is expressed as a percentage of the product's maximum
        noise tolerance fan speed.  This value may exceed 100% in certain cases.
        """

    @property
    def min_max_speed(self) -> tuple[int, int]:
        """
        Retrieves the minimum and maximum fan speed all of the device's fans.

        For all discrete products with dedicated fans.

        Returns
        -------
        tuple[int, int]
            A tuple of (min_speed, max_speed)
        """

    @property
    def control_policy(self) -> FanControlPolicy:
        """
        The current fan control policy.

        For Maxwell™ or newer fully supported devices.

        For all CUDA-capable discrete products with fans.
        """

    def set_default_speed(self) -> None:
        """
        Set the speed of the fan control policy to default.

        For all CUDA-capable discrete products with fans.
        """

class FieldValue:
    """
    Represents the data from a single field value.

    Use :meth:`Device.get_field_values` to get multiple field values at once.
    """

    def __init__(self, field_value: nvml.FieldValue):
        ...

    @property
    def field_id(self) -> FieldId:
        """
        The field ID.
        """

    @property
    def scope_id(self) -> int:
        """
        The scope ID.
        """

    @property
    def timestamp(self) -> int:
        """
        The CPU timestamp (in microseconds since 1970) at which the value was
        sampled.
        """

    @property
    def latency_usec(self) -> int:
        """
        How long this field value took to update (in usec) within NVML. This may
        be averaged across several fields that are serviced by the same driver
        call.
        """

    @property
    def value(self) -> int | float:
        """
        The field value.

        Raises
        ------
        :class:`cuda.core.system.NvmlError`
            If there was an error retrieving the field value.
        """

class FieldValues:
    """
    Container of multiple field values.
    """

    def __init__(self, field_values: nvml.FieldValue):
        ...

    def __getitem__(self, idx: int) -> FieldValue:
        ...

    def __len__(self) -> int:
        ...

    def validate(self) -> None:
        """
        Validate that there are no issues in any of the contained field values.

        Raises an exception for the first issue found, if any.

        Raises
        ------
        :class:`cuda.core.system.NvmlError`
            If any of the contained field values has an associated exception.
        """

    def get_all_values(self) -> list[int | float]:
        """
        Get all field values as a list.

        This will validate each of the values and include just the core value in
        the list.

        Returns
        -------
        list[int | float]
            List of all field values.

        Raises
        ------
        :class:`cuda.core.system.NvmlError`
            If any of the contained field values has an associated exception.
        """

class InforomInfo:

    def __init__(self, device: Device):
        ...

    def get_version(self, inforom: InforomObject | str) -> str:
        """
        Retrieves the InfoROM version for a given InfoROM object.

        For all products with an InfoROM.

        Fermi™ and higher parts have non-volatile on-board memory for persisting
        device info, such as aggregate ECC counts.

        Parameters
        ----------
        inforom: :class:`InforomObject`
            The InfoROM object to query.

        Returns
        -------
        str
            The InfoROM version.
        """

    @property
    def image_version(self) -> str:
        """
        Retrieves the global InfoROM image version.

        For all products with an InfoROM.

        Image version just like VBIOS version uniquely describes the exact
        version of the InfoROM flashed on the board in contrast to InfoROM
        object version which is only an indicator of supported features.

        Returns
        -------
        str
            The InfoROM image version.
        """

    @property
    def configuration_checksum(self) -> int:
        """
        Retrieves the checksum of the configuration stored in the device's InfoROM.

        For all products with an InfoROM.

        Can be used to make sure that two GPUs have the exact same
        configuration.  Current checksum takes into account configuration stored
        in PWR and ECC InfoROM objects.  Checksum can change between driver
        releases or when user changes configuration (e.g. disable/enable ECC)

        Returns
        -------
        int
            The InfoROM checksum.
        """

    def validate(self) -> None:
        """
        Reads the InfoROM from the flash and verifies the checksums.

        For all products with an InfoROM.

        Raises
        ------
        :class:`cuda.core.system.CorruptedInforomError`
            If the device's InfoROM is corrupted.
        """

    @property
    def bbx_flush_time(self) -> tuple[int, int]:
        """
        Retrieves the timestamp and duration of the last flush of the BBX
        (blackbox) InfoROM object during the current run.

        For all products with an InfoROM.

        Returns
        -------
        tuple[int, int]
            - timestamp: The start timestamp of the last BBX flush
            - duration_us: The duration (in μs) of the last BBX flush
        """

    @property
    def board_part_number(self) -> str:
        """
        The device board part number which is programmed into the board's InfoROM.
        """

class MemoryInfo:
    """
    Memory allocation information for a device.
    """

    def __init__(self, memory_info: nvml.Memory_v2):
        ...

    @property
    def free(self) -> int:
        """
        Unallocated device memory (in bytes)
        """

    @property
    def total(self) -> int:
        """
        Total physical device memory (in bytes)
        """

    @property
    def used(self) -> int:
        """
        Allocated device memory (in bytes)
        """

    @property
    def reserved(self) -> int:
        """
        Device memory (in bytes) reserved for system use (driver or firmware)
        """

class BAR1MemoryInfo(MemoryInfo):
    """
    BAR1 Memory allocation information for a device.
    """

    def __init__(self, memory_info: nvml.BAR1Memory):
        ...

    @property
    def free(self) -> int:
        """
        Unallocated BAR1 memory (in bytes)
        """

    @property
    def total(self) -> int:
        """
        Total BAR1 memory (in bytes)
        """

    @property
    def used(self) -> int:
        """
        Allocated used memory (in bytes)
        """

class MigInfo:

    def __init__(self, device: Device):
        ...

    @property
    def is_mig_device(self) -> bool:
        """
        Whether this device is a MIG (Multi-Instance GPU) device.

        A MIG device handle is an NVML abstraction which maps to a MIG compute
        instance.  These overloaded references can be used (with some
        restrictions) interchangeably with a GPU device handle to execute
        queries at a per-compute instance granularity.

        For Ampere™ or newer fully supported devices.
        """

    @property
    def mode(self) -> bool:
        """
        Get current MIG mode for the device.

        For Ampere™ or newer fully supported devices.

        Changing MIG modes may require device unbind or reset. The "pending" MIG
        mode refers to the target mode following the next activation trigger.

        Returns
        -------
        bool
            `True` if current MIG mode is enabled.
        """

    @mode.setter
    def mode(self, mode: bool) -> None:
        """
        Set the MIG mode for the device.

        For Ampere™ or newer fully supported devices.

        Changing MIG modes may require device unbind or reset. The "pending" MIG
        mode refers to the target mode following the next activation trigger.

        Parameters
        ----------
        mode: bool
            `True` to enable MIG mode, `False` to disable MIG mode.
        """

    @property
    def pending_mode(self) -> bool:
        """
        Get pending MIG mode for the device.

        For Ampere™ or newer fully supported devices.

        Changing MIG modes may require device unbind or reset. The "pending" MIG
        mode refers to the target mode following the next activation trigger.

        If the device is not a MIG device, returns `False`.

        Returns
        -------
        bool
            `True` if pending MIG mode is enabled.
        """

    @property
    def device_count(self) -> int:
        """
        Get the maximum number of MIG devices that can exist under this device.

        Returns zero if MIG is not supported or enabled.

        For Ampere™ or newer fully supported devices.

        Returns
        -------
        int
            The number of MIG devices (compute instances) on this GPU.
        """

    @property
    def parent(self) -> Device:
        """
        For MIG devices, get the parent GPU device.

        For Ampere™ or newer fully supported devices.

        Returns
        -------
        Device
            The parent GPU device for this MIG device.
        """

    def get_device_by_index(self, index: int) -> Device:
        """
        Get MIG device for the given index under its parent device.

        If the compute instance is destroyed either explicitly or by destroying,
        resetting or unbinding the parent GPU instance or the GPU device itself
        the MIG device handle would remain invalid and must be requested again
        using this API. Handles may be reused and their properties can change in
        the process.

        For Ampere™ or newer fully supported devices.

        Parameters
        ----------
        index: int
            The index of the MIG device (compute instance) to retrieve.  Must be
            between 0 and the value returned by `device_count - 1`.

        Returns
        -------
        Device
            The MIG device corresponding to the given index.
        """

    def get_all_devices(self) -> Iterable[Device]:
        """
        Get all MIG devices under its parent device.

        If the compute instance is destroyed either explicitly or by destroying,
        resetting or unbinding the parent GPU instance or the GPU device itself
        the MIG device handle would remain invalid and must be requested again
        using this API. Handles may be reused and their properties can change in
        the process.

        For Ampere™ or newer fully supported devices.

        Returns
        -------
        list[Device]
            A list of all MIG devices corresponding to this GPU.
        """

class _NvlinkInfoMeta(type):

    @property
    def max_links(cls):
        """
        The statically-defined maximum number of Nvlinks available.  Defined in
        upstream NVML as ``NVML_NVLINK_MAX_LINKS``.

        To find the actual number of Nvlinks available on a device, use
        :py:attr:`Device.get_nvlink_count`.

        .. version-deprecated:: 1.1.0
            This property is deprecated and will be removed in a future release.
            Use :py:attr:`Device.get_nvlink_count` instead.
        """

class _NvlinkInfo:
    """
    Nvlink information for a device.
    """

    def __init__(self, device: Device, link: int):
        ...

    @property
    def version(self) -> tuple[int, int]:
        """
        Retrieves the NvLink version for the device and link.

        For all products with NvLink support.

        Returns
        -------
        tuple[int, int]
            The Nvlink version as a tuple of (major, minor).
        """

    @property
    def state(self) -> bool:
        """
        Retrieves the state of the device's Nvlink for the device and link specified.

        For Pascal™ or newer fully supported devices.

        For all products with Nvlink support.

        Returns
        -------
        bool
            `True` if the Nvlink is active.
        """

class NvlinkInfo(_NvlinkInfo, metaclass=_NvlinkInfoMeta):
    ...

class PciInfo:
    """
    PCI information about a GPU device.
    """

    def __init__(self, pci_info_ext: nvml.PciInfoExt_v1, handle: int):
        ...

    @property
    def bus(self) -> int:
        """
        The bus on which the device resides, 0 to 255
        """

    @property
    def bus_id(self) -> str:
        """
        The tuple domain:bus:device.function PCI identifier string
        """

    @property
    def device(self) -> int:
        """
        The device's id on the bus, 0 to 31
        """

    @property
    def domain(self) -> int:
        """
        The PCI domain on which the device's bus resides, 0 to 0xffffffff
        """

    @property
    def vendor_id(self) -> int:
        """
        The PCI vendor id of the device
        """

    @property
    def device_id(self) -> int:
        """
        The PCI device id of the device
        """

    @property
    def subsystem_id(self) -> int:
        """
        The subsystem device ID
        """

    @property
    def base_class(self) -> int:
        """
        The 8-bit PCI base class code
        """

    @property
    def sub_class(self) -> int:
        """
        The 8-bit PCI sub class code
        """

    @property
    def link_generation(self) -> int:
        """
        Retrieve the maximum PCIe link generation possible with this device and system.

        For Fermi™ or newer fully supported devices.

        For example, for a generation 2 PCIe device attached to a generation 1
        PCIe bus, the max link generation this function will report is
        generation 1.
        """

    @property
    def max_link_generation(self) -> int:
        """
        Retrieve the maximum PCIe link generation supported by this GPU device.

        For Fermi™ or newer fully supported devices.
        """

    @property
    def max_link_width(self) -> int:
        """
        Retrieve the maximum PCIe link width possible with this device and system.

        For Fermi™ or newer fully supported devices.

        For example, for a device with a 16x PCIe bus width attached to a 8x
        PCIe system bus this function will report
        a max link width of 8.
        """

    @property
    def current_link_generation(self) -> int:
        """
        Retrieve the current PCIe link generation.

        For Fermi™ or newer fully supported devices.
        """

    @property
    def current_link_width(self) -> int:
        """
        Retrieve the current PCIe link width.

        For Fermi™ or newer fully supported devices.
        """

    @property
    def rx_throughput(self) -> int:
        """
        Retrieve PCIe reception throughput, in KB/s.

        This function is querying a byte counter over a 20ms interval, and thus
        is the PCIe throughput over that interval.

        For Maxwell™ or newer fully supported devices.

        This method is not supported in virtual machines running virtual GPU
        (vGPU).
        """

    @property
    def tx_throughput(self) -> int:
        """
        Retrieve PCIe transmission throughput, in KB/s.

        This function is querying a byte counter over a 20ms interval, and thus
        is the PCIe throughput over that interval.

        For Maxwell™ or newer fully supported devices.

        This method is not supported in virtual machines running virtual GPU
        (vGPU).
        """

    @property
    def replay_counter(self) -> int:
        """
        Retrieve the PCIe replay counter.

        For Kepler™ or newer fully supported devices.
        """

class GpuDynamicPstatesUtilization:

    def __init__(self, ptr: int, owner: object):
        ...

    @property
    def is_present(self) -> bool:
        """
        Set if the utilization domain is present on this GPU.
        """

    @property
    def percentage(self) -> int:
        """
        Percentage of time where the domain is considered busy in the last 1-second interval.
        """

    @property
    def inc_threshold(self) -> int:
        """
        Utilization threshold that can trigger a perf-increasing P-State change when crossed.
        """

    @property
    def dec_threshold(self) -> int:
        """
        Utilization threshold that can trigger a perf-decreasing P-State change when crossed.
        """

class GpuDynamicPstatesInfo:
    """
    Handles performance monitor samples from the device.
    """

    def __init__(self, gpu_dynamic_pstates_info: nvml.GpuDynamicPstatesInfo):
        ...

    def __len__(self) -> int:
        ...

    def __getitem__(self, idx: int) -> GpuDynamicPstatesUtilization:
        ...

class ProcessInfo:
    """
    Information about running compute processes on the GPU.
    """

    def __init__(self, device: Device, process_info: nvml.ProcessInfo):
        ...

    @property
    def pid(self) -> int:
        """
        The PID of the process.
        """

    @property
    def used_gpu_memory(self) -> int:
        """
        The amount of GPU memory (in bytes) used by the process.
        """

    @property
    def gpu_instance_id(self) -> int:
        """
        The GPU instance ID for MIG devices.

        Only valid for processes running on MIG devices.
        """

    @property
    def compute_instance_id(self) -> int:
        """
        The Compute instance ID for MIG devices.

        Only valid for processes running on MIG devices.
        """

class RepairStatus:
    """
    Repair status for TPC/Channel repair.
    """

    def __init__(self, handle: int):
        ...

    @property
    def channel_repair_pending(self) -> bool:
        """
        `True` if a channel repair is pending.
        """

    @property
    def tpc_repair_pending(self) -> bool:
        """
        `True` if a TPC repair is pending.
        """

class ThermalSensor:

    def __init__(self, ptr: int, owner: object):
        ...

    @property
    def controller(self) -> ThermalController:
        ...

    @property
    def default_min_temp(self) -> int:
        ...

    @property
    def default_max_temp(self) -> int:
        ...

    @property
    def current_temp(self) -> int:
        ...

    @property
    def target(self) -> ThermalTarget:
        ...

class ThermalSettings:

    def __init__(self, thermal_settings: nvml.ThermalSettings):
        ...

    def __len__(self) -> int:
        ...

    def __getitem__(self, idx: int) -> nvml.ThermalSensor:
        ...

class Temperature:

    def __init__(self, handle: int):
        ...

    def get_sensor(self) -> int:
        """
        Get the temperature reading from a specific sensor on the device, in
        degrees Celsius.

        The only sensor currently supported is the GPU temperature sensor.

        Returns
        -------
        int
            The temperature in degrees Celsius.
        """

    def get_threshold(self, threshold_type: TemperatureThresholds | str) -> int:
        """
        Retrieves the temperature threshold for this GPU with the specified
        threshold type, in degrees Celsius.

        For Kepler™ or newer fully supported devices.

        See :class:`TemperatureThresholds` for possible threshold types.

        Note: This API is no longer the preferred interface for retrieving the
        following temperature thresholds on Ada and later architectures:
        ``NVML_TEMPERATURE_THRESHOLD_SHUTDOWN``,
        ``NVML_TEMPERATURE_THRESHOLD_SLOWDOWN``,
        ``NVML_TEMPERATURE_THRESHOLD_MEM_MAX`` and
        ``NVML_TEMPERATURE_THRESHOLD_GPU_MAX``.

        Support for reading these temperature thresholds for Ada and later
        architectures would be removed from this API in future releases. Please
        use :meth:`get_field_values` with ``NVML_FI_DEV_TEMPERATURE_*`` fields
        to retrieve temperature thresholds on these architectures.
        """

    @property
    def margin(self) -> int:
        """
        The thermal margin temperature (distance to nearest slowdown threshold) for the device.
        """

    def get_thermal_settings(self, sensor_index: ThermalTarget | str) -> ThermalSettings:
        """
        Used to execute a list of thermal system instructions.

        Parameters
        ----------
        sensor_index: ThermalTarget
            The index of the thermal sensor.

        Returns
        -------
        :obj:`~_device.ThermalSettings`
            The thermal settings for the specified sensor.
        """

class Utilization:
    """
    Utilization rates for a device.

    For devices with compute capability 2.0 or higher.
    """

    def __init__(self, utilization: nvml.Utilization):
        ...

    @property
    def gpu(self) -> int:
        """
        Percent of time over the past sample period during which one or more kernels was executing on the GPU.
        """

    @property
    def memory(self) -> int:
        """
        Percent of time over the past sample period during which global (device) memory was being read or written.
        """

class Device:
    """
    Representation of a device.

    :class:`cuda.core.system.Device` provides access to various pieces of metadata
    about devices and their topology, as provided by the NVIDIA Management
    Library (NVML).  To use CUDA with a device, use :class:`cuda.core.Device`.

    Creating a device instance causes NVML to initialize the target GPU.
    NVML may initialize additional GPUs if the target GPU is an SLI slave.

    Parameters
    ----------
    index: int, optional
        Integer representing the CUDA device index to get a handle to.  Valid
        values are between ``0`` and ``cuda.core.system.get_num_devices() - 1``.

        The order in which devices are enumerated has no guarantees of
        consistency between reboots.  For that reason, it is recommended that
        devices are looked up by their PCI ids or UUID.

    uuid: bytes or str, optional
        UUID of a CUDA device to get a handle to.

    pci_bus_id: bytes or str, optional
        PCI bus ID of a CUDA device to get a handle to.

    Raises
    ------
    ValueError
        If anything other than a single `index`, `uuid` or `pci_bus_id` are specified.
    """
    _handle: int

    def __init__(self, *, index: int | None=None, uuid: bytes | str | None=None, pci_bus_id: bytes | str | None=None) -> None:
        ...

    @property
    def index(self) -> int:
        """
        The NVML index of this device.

        Valid indices are derived from the count returned by
        :meth:`Device.get_device_count`.  For example, if ``get_device_count()``
        returns 2, the valid indices are 0 and 1, corresponding to GPU 0 and GPU
        1.

        The order in which NVML enumerates devices has no guarantees of
        consistency between reboots. For that reason, it is recommended that
        devices be looked up by their PCI ids or GPU UUID.

        Note: The NVML index may not correlate with other APIs, such as the CUDA
        device index.
        """

    @property
    def uuid(self) -> str:
        """
        Retrieves the globally unique immutable UUID associated with this
        device, as a 5 part hexadecimal string, that augments the immutable,
        board serial identifier.

        In the upstream NVML C++ API, the UUID includes a ``gpu-`` or ``mig-``
        prefix.  If you need a `uuid` without that prefix (for example, to
        interact with CUDA), use the `uuid_without_prefix` property.
        """

    @property
    def uuid_without_prefix(self) -> str:
        """
        Retrieves the globally unique immutable UUID associated with this
        device, as a 5 part hexadecimal string, that augments the immutable,
        board serial identifier.

        In the upstream NVML C++ API, the UUID includes a ``gpu-`` or ``mig-``
        prefix.  This property returns it without the prefix, to match the UUIDs
        used in CUDA.  If you need the prefix, use the `uuid` property.
        """

    @property
    def pci_bus_id(self) -> str:
        """
        Retrieves the PCI bus ID of this device.
        """

    @property
    def numa_node_id(self) -> int:
        """
        The NUMA node of the given GPU device.

        This only applies to platforms where the GPUs are NUMA nodes.
        """

    @property
    def arch(self) -> DeviceArch:
        """
        :obj:`~DeviceArch` device architecture.

        For example, a Tesla V100 will report ``DeviceArchitecture.name ==
        "VOLTA"``, and RTX A6000 will report ``DeviceArchitecture.name ==
        "AMPERE"``.
        """

    @property
    def name(self) -> str:
        """
        Name of the device, e.g.: `"Tesla V100-SXM2-32GB"`
        """

    @property
    def brand(self) -> str:
        """
        The brand of the device.

        Returns "Unknown" if the brand is unknown.
        """

    @property
    def serial(self) -> str:
        """
        Retrieves the globally unique board serial number associated with this
        device's board.

        For all products with an InfoROM.
        """

    @property
    def module_id(self) -> int:
        """
        Get a unique identifier for the device module on the baseboard.

        This API retrieves a unique identifier for each GPU module that exists
        on a given baseboard.  For non-baseboard products, this ID would always
        be 0.
        """

    @property
    def minor_number(self) -> int:
        """
        The minor number of this device.

        For Linux only.

        The minor number is used by the Linux device driver to identify the
        device node in ``/dev/nvidiaX``.
        """

    @property
    def is_c2c_enabled(self) -> bool:
        """
        Whether the C2C (Chip-to-Chip) mode is enabled for this device.
        """

    @property
    def is_persistence_mode_enabled(self) -> bool:
        """
        Whether persistence mode is enabled for this device.

        For Linux only.
        """

    @is_persistence_mode_enabled.setter
    def is_persistence_mode_enabled(self, enabled: bool) -> None:
        ...

    @property
    def cuda_compute_capability(self) -> tuple[int, int]:
        """
        CUDA compute capability of the device, e.g.: `(7, 0)` for a Tesla V100.

        Returns a tuple `(major, minor)`.
        """

    def to_cuda_device(self) -> 'cuda.core.Device':
        """
        Get the corresponding :class:`cuda.core.Device` (which is used for CUDA
        access) for this :class:`cuda.core.system.Device` (which is used for
        NVIDIA Management Library (NVML) access).

        The devices are mapped to one another by their UUID.

        Returns
        -------
        cuda.core.Device
            The corresponding CUDA device.

        Raises
        ------
        RuntimeError
            No corresponding CUDA device is found for this NVML device.

            For example, on a MIG system, the physical GPU will not have an
            available CUDA device, since it can not be used directly, even
            though it can be enumerated from NVML.
        """

    @classmethod
    def get_device_count(cls) -> int:
        """
        Get the number of available devices.

        Returns
        -------
        int
            The number of available devices.
        """

    @classmethod
    def get_all_devices(cls) -> Iterable[Device]:
        """
        Query the available device instances.

        Returns
        -------
        Iterator over :obj:`~Device`
            An iterator over available devices.
        """

    @property
    def addressing_mode(self) -> AddressingMode | None:
        """
        Get the :obj:`~AddressingMode` of the device.
        """

    @property
    def mig(self) -> MigInfo:
        """
        Get :obj:`~MigInfo` accessor for MIG (Multi-Instance GPU) information.

        For Ampere™ or newer fully supported devices.
        """

    @classmethod
    def get_all_devices_with_cpu_affinity(cls, cpu_index: int) -> Iterable[Device]:
        """
        Retrieve the set of GPUs that have a CPU affinity with the given CPU number.

        Supported on Linux only.

        Parameters
        ----------
        cpu_index: int
            The CPU index.

        Returns
        -------
        Iterator of :obj:`~Device`
            An iterator over available devices.
        """

    def get_memory_affinity(self, scope: AffinityScope | str=...) -> list[int]:
        """
        Retrieves a list of indices of NUMA nodes or CPU sockets with the ideal
        memory affinity for the device.

        For Kepler™ or newer fully supported devices.

        Supported on Linux only.

        If requested scope is not applicable to the target topology, the API
        will fall back to reporting the memory affinity for the immediate non-I/O
        ancestor of the device.

        Parameters
        ----------
        scope: AffinityScope | str, optional
            The scope of the affinity query.  Must be one of the values of
            :class:`AffinityScope`.  Default is :attr:`AffinityScope.NODE`.

        Returns
        -------
        list[int]
            A list of indices of NUMA nodes or CPU sockets with the ideal memory
            affinity for the device.
        """

    def get_cpu_affinity(self, scope: AffinityScope | str=...) -> list[int]:
        """
        Retrieves a list of indices of NUMA nodes or CPU sockets with the ideal
        CPU affinity for the device.

        For Kepler™ or newer fully supported devices.

        Supported on Linux only.

        If requested scope is not applicable to the target topology, the API
        will fall back to reporting the memory affinity for the immediate non-I/O
        ancestor of the device.

        Parameters
        ----------
        scope: AffinityScope | str, optional
            The scope of the affinity query.  Must be one of the values of
            :class:`AffinityScope`.  Default is :attr:`AffinityScope.NODE`.

        Returns
        -------
        list[int]
            A list of indices of NUMA nodes or CPU sockets with the ideal memory
            affinity for the device.
        """

    def set_cpu_affinity(self) -> None:
        """
        Sets the ideal affinity for the calling thread and device.

        For Kepler™ or newer fully supported devices.

        Supported on Linux only.
        """

    def clear_cpu_affinity(self) -> None:
        """
        Clear all affinity bindings for the calling thread.

        For Kepler™ or newer fully supported devices.

        Supported on Linux only.
        """

    def get_clock(self, clock_type: ClockType | str) -> ClockInfo:
        """
        :obj:`~_device.ClockInfo` object to get information about and manage a specific clock on a device.
        """

    @property
    def is_auto_boosted_clocks_enabled(self) -> tuple[bool, bool]:
        """
        Retrieve the current state of auto boosted clocks on a device.

        For Kepler™ or newer fully supported devices.

        Auto Boosted clocks are enabled by default on some hardware, allowing
        the GPU to run at higher clock rates to maximize performance as thermal
        limits allow.

        On Pascal™ and newer hardware, Auto Boosted clocks are controlled
        through application clocks. Use :meth:`set_application_clocks` and
        :meth:`reset_application_clocks` to control Auto Boost behavior.

        Returns
        -------
        bool
            The current state of Auto Boosted clocks
        bool
            The default Auto Boosted clocks behavior

        """

    @property
    def current_clock_event_reasons(self) -> list[ClocksEventReasons]:
        """
        Retrieves the current :obj:`~ClocksEventReasons`.

        For all fully supported products.
        """

    @property
    def supported_clock_event_reasons(self) -> list[ClocksEventReasons]:
        """
        Retrieves supported :obj:`~ClocksEventReasons` that can be returned by
        :meth:`get_current_clock_event_reasons`.

        For all fully supported products.

        This method is not supported in virtual machines running virtual GPU (vGPU).
        """

    @property
    def cooler(self) -> CoolerInfo:
        """
        :obj:`~_device.CoolerInfo` object with cooler information for the device.
        """

    @property
    def attributes(self) -> DeviceAttributes:
        """
        :obj:`~_device.DeviceAttributes` object with various device attributes.

        For Ampere™ or newer fully supported devices.  Only available on Linux
        systems.
        """

    @property
    def is_display_connected(self) -> bool:
        """
        The display mode for this device.

        Indicates whether a physical display (e.g. monitor) is currently connected to
        any of the device's connectors.
        """

    @property
    def is_display_active(self) -> bool:
        """
        The display active status for this device.

        Indicates whether a display is initialized on the device.  For example,
        whether X Server is attached to this device and has allocated memory for
        the screen.

        Display can be active even when no monitor is physically attached.
        """

    def register_events(self, events: EventType | str | list[EventType | str]) -> DeviceEvents:
        """
        Starts recording events on this device.

        For Fermi™ or newer fully supported devices.  For Linux only.

        ECC events are available only on ECC-enabled devices (see
        :meth:`Device.get_total_ecc_errors`).  Power capping events are
        available only on Power Management enabled devices (see
        :meth:`Device.get_power_management_mode`).

        This call starts recording of events on specific device.  All events
        that occurred before this call are not recorded.  Wait for events using
        the :meth:`DeviceEvents.wait` method on the result.

        Examples
        --------
        >>> device = Device(index=0)
        >>> events = device.register_events([
        ...     EventType.XID_CRITICAL_ERROR,
        ... ])
        >>> while event := events.wait(timeout_ms=10000):
        ...     print(f"Event {event.event_type} occurred on device {event.device.uuid}")

        Parameters
        ----------
        events: EventType, str, or list of EventType or str
            The event type or list of event types to register for this device.

        Returns
        -------
        :obj:`~_device.DeviceEvents`
            An object representing the registered events.  Call
            :meth:`~_device.DeviceEvents.wait` on this object to wait for events.

        Raises
        ------
        :class:`cuda.core.system.NotSupportedError`
            None of the requested event types are registered.
        """

    def get_supported_event_types(self) -> list[EventType]:
        """
        Get the list of event types supported by this device.

        For Fermi™ or newer fully supported devices.  For Linux only (returns an
        empty list on Windows).

        Returns
        -------
        list[EventType]
            The list of supported event types.
        """

    def get_fan(self, fan: int=0) -> FanInfo:
        """
        :obj:`~_device.FanInfo` object to get information and manage a specific fan on a device.
        """

    @property
    def num_fans(self) -> int:
        """
        The number of fans on the device.
        """

    def get_field_values(self, field_ids: list[int | tuple[int, int]]) -> FieldValues:
        """
        Get multiple field values from the device.

        Each value specified can raise its own exception.  That exception will
        be raised when attempting to access the corresponding ``value`` from the
        returned :obj:`~_device.FieldValues` container.

        To confirm that there are no exceptions in the entire container, call
        :meth:`~_device.FieldValues.validate`.

        Parameters
        ----------
        field_ids: list[int | tuple[int, int]]
            List of field IDs to query.

            Each item may be either a single value from the :class:`FieldId`
            enum, or a pair of (:class:`FieldId`, scope ID).

        Returns
        -------
        :obj:`~_device.FieldValues`
            Container of field values corresponding to the requested field IDs.
        """

    def clear_field_values(self, field_ids: list[int | tuple[int, int]]) -> None:
        """
        Clear multiple field values from the device.

        Parameters
        ----------
        field_ids: list[int | tuple[int, int]]
            List of field IDs to clear.

            Each item may be either a single value from the :class:`FieldId`
            enum, or a pair of (:class:`FieldId`, scope ID).
        """

    @property
    def inforom(self) -> InforomInfo:
        """
        :obj:`~_device.InforomInfo` object with InfoROM information.

        For all products with an InfoROM.
        """

    @property
    def bar1_memory_info(self) -> BAR1MemoryInfo:
        """
        :obj:`~_device.BAR1MemoryInfo` object with BAR1 memory information.

        BAR1 is used to map the FB (device memory) so that it can be directly
        accessed by the CPU or by 3rd party devices (peer-to-peer on the PCIE
        bus).
        """

    @property
    def memory_info(self) -> MemoryInfo:
        """
        :obj:`~_device.MemoryInfo` object with memory information.
        """

    def get_nvlink(self, link: int) -> NvlinkInfo:
        """
        Get :obj:`~NvlinkInfo` about this device.

        For devices with NVLink support.

        .. version-changed:: 1.1.0
            Any link number not supported by this specific device will raise a `ValueError`.
        """

    def get_nvlink_count(self) -> int:
        """
        Get the number of NVLink links on this device.

        For devices with NVLink support.

        .. version-added:: 1.1.0
        """

    def get_nvlinks(self) -> Iterable[NvlinkInfo]:
        """
        Get :obj:`~NvlinkInfo` about all NVLink links on this device.

        For devices with NVLink support.

        .. version-added:: 1.1.0
        """

    @property
    def pci_info(self) -> PciInfo:
        """
        :obj:`~_device.PciInfo` object with the PCI attributes of this device.

        Non-physical devices, such as MIG devices, may not have PCI attributes.
        In that case, this property will raise a `RuntimeError`.
        """

    @property
    def performance_state(self) -> int | None:
        """
        The current performance state of the device.

        For Fermi™ or newer fully supported devices.

        Returns
        -------
        int | None
            The current performance state of the device, as an integer between 0 and 15,
            where 0 is maximum performance and higher numbers are lower performance.
            Returns `None` if the performance state is unknown.
        """

    @property
    def dynamic_pstates_info(self) -> GpuDynamicPstatesInfo:
        """
        :obj:`~_device.GpuDynamicPstatesInfo` object with performance monitor samples from the associated subdevice.
        """

    @property
    def supported_pstates(self) -> list[int]:
        """
        Get all supported Performance States (P-States) for the device.

        The returned list contains a contiguous list of valid P-States supported by
        the device.

        Return
        ------
        list[int]
            A list of supported performance state of the device, as an integer
            between 0 and 15, where 0 is maximum performance and higher numbers
            are lower performance.
        """

    @property
    def compute_running_processes(self) -> list[ProcessInfo]:
        """
        Get information about processes with a compute context on a device

        For Fermi™ or newer fully supported devices.

        This function returns information only about compute running processes
        (e.g. CUDA application which have active context). Any graphics
        applications (e.g. using OpenGL, DirectX) won't be listed by this
        function.

        Keep in mind that information returned by this call is dynamic and the
        number of elements might change in time.

        In MIG mode, if device handle is provided, the API returns aggregate
        information, only if the caller has appropriate privileges. Per-instance
        information can be queried by using specific MIG device handles.
        Querying per-instance information using MIG device handles is not
        supported if the device is in vGPU Host virtualization mode.
        """

    @property
    def repair_status(self) -> RepairStatus:
        """
        :obj:`~_device.RepairStatus` object with TPC/Channel repair status.

        For Ampere™ or newer fully supported devices.
        """

    @property
    def temperature(self) -> Temperature:
        """
        :obj:`~_device.Temperature` object with temperature information for the device.
        """

    def get_topology_nearest_gpus(self, level: GpuTopologyLevel | str) -> Iterable[Device]:
        """
        Retrieve the GPUs that are nearest to this device at a specific interconnectivity level.

        Supported on Linux only.

        Parameters
        ----------
        level: :class:`GpuTopologyLevel`
            The topology level.

        Returns
        -------
        Iterable of :class:`Device`
            The nearest devices at the given topology level.
        """

    @property
    def utilization(self) -> Utilization:
        """
        Retrieves the current :obj:`~Utilization` rates for the device's major
        subsystems.

        For Fermi™ or newer fully supported devices.

        Note: During driver initialization when ECC is enabled one can see high
        GPU and Memory Utilization readings.  This is caused by ECC Memory
        Scrubbing mechanism that is performed during driver initialization.

        Note: On MIG-enabled GPUs, querying device utilization rates is not
        currently supported.

        Returns
        -------
        Utilization
            An object containing the current utilization rates for the device.
        """
_CLOCK_ID_MAPPING = {ClockId.CURRENT: nvml.ClockId.CURRENT, ClockId.CUSTOMER_BOOST_MAX: nvml.ClockId.CUSTOMER_BOOST_MAX}
_CLOCKS_EVENT_REASONS_MAPPING = {nvml.ClocksEventReasons.EVENT_REASON_NONE: ClocksEventReasons.NONE, nvml.ClocksEventReasons.EVENT_REASON_GPU_IDLE: ClocksEventReasons.GPU_IDLE, nvml.ClocksEventReasons.EVENT_REASON_APPLICATIONS_CLOCKS_SETTING: ClocksEventReasons.APPLICATIONS_CLOCKS_SETTING, nvml.ClocksEventReasons.EVENT_REASON_SW_POWER_CAP: ClocksEventReasons.SW_POWER_CAP, nvml.ClocksEventReasons.THROTTLE_REASON_HW_SLOWDOWN: ClocksEventReasons.HW_SLOWDOWN, nvml.ClocksEventReasons.EVENT_REASON_SYNC_BOOST: ClocksEventReasons.SYNC_BOOST, nvml.ClocksEventReasons.EVENT_REASON_SW_THERMAL_SLOWDOWN: ClocksEventReasons.SW_THERMAL_SLOWDOWN, nvml.ClocksEventReasons.THROTTLE_REASON_HW_THERMAL_SLOWDOWN: ClocksEventReasons.HW_THERMAL_SLOWDOWN, nvml.ClocksEventReasons.THROTTLE_REASON_HW_POWER_BRAKE_SLOWDOWN: ClocksEventReasons.HW_POWER_BRAKE_SLOWDOWN, nvml.ClocksEventReasons.EVENT_REASON_DISPLAY_CLOCK_SETTING: ClocksEventReasons.DISPLAY_CLOCK_SETTING}
_CLOCK_TYPE_MAPPING = {ClockType.GRAPHICS: nvml.ClockType.CLOCK_GRAPHICS, ClockType.SM: nvml.ClockType.CLOCK_SM, ClockType.MEMORY: nvml.ClockType.CLOCK_MEM, ClockType.VIDEO: nvml.ClockType.CLOCK_VIDEO}
_COOLER_CONTROL_MAPPING = {nvml.CoolerControl.THERMAL_COOLER_SIGNAL_TOGGLE: CoolerControl.TOGGLE, nvml.CoolerControl.THERMAL_COOLER_SIGNAL_VARIABLE: CoolerControl.VARIABLE}
_COOLER_TARGET_MAPPING = {nvml.CoolerTarget.THERMAL_NONE: CoolerTarget.NONE, nvml.CoolerTarget.THERMAL_GPU: CoolerTarget.GPU, nvml.CoolerTarget.THERMAL_MEMORY: CoolerTarget.MEMORY, nvml.CoolerTarget.THERMAL_POWER_SUPPLY: CoolerTarget.POWER_SUPPLY}
_EVENT_TYPE_MAPPING = {nvml.EventType.NONE: EventType.NONE, nvml.EventType.SINGLE_BIT_ECC_ERROR: EventType.SINGLE_BIT_ECC_ERROR, nvml.EventType.DOUBLE_BIT_ECC_ERROR: EventType.DOUBLE_BIT_ECC_ERROR, nvml.EventType.PSTATE: EventType.PSTATE, nvml.EventType.XID_CRITICAL_ERROR: EventType.XID_CRITICAL_ERROR, nvml.EventType.CLOCK: EventType.CLOCK, nvml.EventType.POWER_SOURCE_CHANGE: EventType.POWER_SOURCE_CHANGE, nvml.EventType.MIG_CONFIG_CHANGE: EventType.MIG_CONFIG_CHANGE, nvml.EventType.SINGLE_BIT_ECC_ERROR_STORM: EventType.SINGLE_BIT_ECC_ERROR_STORM, nvml.EventType.DRAM_RETIREMENT_EVENT: EventType.DRAM_RETIREMENT_EVENT, nvml.EventType.DRAM_RETIREMENT_FAILURE: EventType.DRAM_RETIREMENT_FAILURE, nvml.EventType.NON_FATAL_POISON_ERROR: EventType.NON_FATAL_POISON_ERROR, nvml.EventType.FATAL_POISON_ERROR: EventType.FATAL_POISON_ERROR, nvml.EventType.GPU_UNAVAILABLE_ERROR: EventType.GPU_UNAVAILABLE_ERROR, nvml.EventType.GPU_RECOVERY_ACTION: EventType.GPU_RECOVERY_ACTION}
_EVENT_TYPE_INV_MAPPING = {v: k for k, v in _EVENT_TYPE_MAPPING.items()}
_FAN_CONTROL_POLICY_MAPPING = {nvml.FanControlPolicy.TEMPERATURE_CONTINUOUS_SW: FanControlPolicy.TEMPERATURE_CONTROLLED, nvml.FanControlPolicy.MANUAL: FanControlPolicy.MANUAL}
_INFOROM_OBJECT_MAPPING = {InforomObject.OEM: nvml.InforomObject.INFOROM_OEM, InforomObject.ECC: nvml.InforomObject.INFOROM_ECC, InforomObject.POWER: nvml.InforomObject.INFOROM_POWER, InforomObject.DEN: nvml.InforomObject.INFOROM_DEN}
_NVLINK_VERSION_MAPPING = {nvml.NvlinkVersion.VERSION_1_0: (1, 0), nvml.NvlinkVersion.VERSION_2_0: (2, 0), nvml.NvlinkVersion.VERSION_2_2: (2, 2), nvml.NvlinkVersion.VERSION_3_0: (3, 0), nvml.NvlinkVersion.VERSION_3_1: (3, 1), nvml.NvlinkVersion.VERSION_4_0: (4, 0), nvml.NvlinkVersion.VERSION_5_0: (5, 0)}
_NVLINK_VERSION_6_0 = getattr(nvml.NvlinkVersion, 'VERSION_6_0', None)
_TEMPERATURE_THRESHOLD_MAPPING = {TemperatureThresholds.SHUTDOWN: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_SHUTDOWN, TemperatureThresholds.SLOWDOWN: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_SLOWDOWN, TemperatureThresholds.MEM_MAX: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_MEM_MAX, TemperatureThresholds.GPU_MAX: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_GPU_MAX, TemperatureThresholds.ACOUSTIC_MIN: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_ACOUSTIC_MIN, TemperatureThresholds.ACOUSTIC_CURR: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_ACOUSTIC_CURR, TemperatureThresholds.ACOUSTIC_MAX: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_ACOUSTIC_MAX, TemperatureThresholds.GPS_CURR: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_GPS_CURR}
_THERMAL_CONTROLLER_MAPPING = {nvml.ThermalController.GPU_INTERNAL: ThermalController.GPU_INTERNAL, nvml.ThermalController.ADM1032: ThermalController.ADM1032, nvml.ThermalController.ADT7461: ThermalController.ADT7461, nvml.ThermalController.MAX6649: ThermalController.MAX6649, nvml.ThermalController.MAX1617: ThermalController.MAX1617, nvml.ThermalController.LM99: ThermalController.LM99, nvml.ThermalController.LM89: ThermalController.LM89, nvml.ThermalController.LM64: ThermalController.LM64, nvml.ThermalController.G781: ThermalController.G781, nvml.ThermalController.ADT7473: ThermalController.ADT7473, nvml.ThermalController.SBMAX6649: ThermalController.SBMAX6649, nvml.ThermalController.VBIOSEVT: ThermalController.VBIOSEVT, nvml.ThermalController.OS: ThermalController.OS, nvml.ThermalController.NVSYSCON_CANOAS: ThermalController.NVSYSCON_CANOAS, nvml.ThermalController.NVSYSCON_E551: ThermalController.NVSYSCON_E551, nvml.ThermalController.MAX6649R: ThermalController.MAX6649R, nvml.ThermalController.ADT7473S: ThermalController.ADT7473S, nvml.ThermalController.UNKNOWN: ThermalController.UNKNOWN}
_THERMAL_TARGET_MAPPING = {nvml.ThermalTarget.NONE: ThermalTarget.NONE, nvml.ThermalTarget.GPU: ThermalTarget.GPU, nvml.ThermalTarget.MEMORY: ThermalTarget.MEMORY, nvml.ThermalTarget.POWER_SUPPLY: ThermalTarget.POWER_SUPPLY, nvml.ThermalTarget.BOARD: ThermalTarget.BOARD, nvml.ThermalTarget.VCD_BOARD: ThermalTarget.VCD_BOARD, nvml.ThermalTarget.VCD_INLET: ThermalTarget.VCD_INLET, nvml.ThermalTarget.VCD_OUTLET: ThermalTarget.VCD_OUTLET, nvml.ThermalTarget.ALL: ThermalTarget.ALL}
_THERMAL_TARGET_INV_MAPPING = {v: k for k, v in _THERMAL_TARGET_MAPPING.items()}
_ADDRESSING_MODE_MAPPING = {nvml.DeviceAddressingModeType.DEVICE_ADDRESSING_MODE_HMM: AddressingMode.HMM, nvml.DeviceAddressingModeType.DEVICE_ADDRESSING_MODE_ATS: AddressingMode.ATS}
_AFFINITY_SCOPE_MAPPING = {AffinityScope.NODE: nvml.AffinityScope.NODE, AffinityScope.SOCKET: nvml.AffinityScope.SOCKET}
_BRAND_TYPE_MAPPING = {nvml.BrandType.BRAND_UNKNOWN: 'Unknown', nvml.BrandType.BRAND_QUADRO: 'Quadro', nvml.BrandType.BRAND_TESLA: 'Tesla', nvml.BrandType.BRAND_NVS: 'NVS', nvml.BrandType.BRAND_GRID: 'GRID', nvml.BrandType.BRAND_GEFORCE: 'GeForce', nvml.BrandType.BRAND_TITAN: 'Titan', nvml.BrandType.BRAND_NVIDIA_VAPPS: 'NVIDIA vApps', nvml.BrandType.BRAND_NVIDIA_VPC: 'NVIDIA VPC', nvml.BrandType.BRAND_NVIDIA_VCS: 'NVIDIA VCS', nvml.BrandType.BRAND_NVIDIA_VWS: 'NVIDIA VWS', nvml.BrandType.BRAND_NVIDIA_CLOUD_GAMING: 'NVIDIA Cloud Gaming', nvml.BrandType.BRAND_NVIDIA_VGAMING: 'NVIDIA vGaming', nvml.BrandType.BRAND_QUADRO_RTX: 'Quadro RTX', nvml.BrandType.BRAND_NVIDIA_RTX: 'NVIDIA RTX', nvml.BrandType.BRAND_NVIDIA: 'NVIDIA', nvml.BrandType.BRAND_GEFORCE_RTX: 'GeForce RTX', nvml.BrandType.BRAND_TITAN_RTX: 'Titan RTX'}
_GPU_P2P_CAPS_INDEX_MAPPING = {GpuP2PCapsIndex.READ: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_READ, GpuP2PCapsIndex.WRITE: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_WRITE, GpuP2PCapsIndex.NVLINK: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_NVLINK, GpuP2PCapsIndex.ATOMICS: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_ATOMICS, GpuP2PCapsIndex.PCI: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_PCI, GpuP2PCapsIndex.PROP: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_PROP, GpuP2PCapsIndex.UNKNOWN: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_UNKNOWN}
_GPU_P2P_STATUS_MAPPING = {nvml.GpuP2PStatus.P2P_STATUS_OK: GpuP2PStatus.OK, nvml.GpuP2PStatus.P2P_STATUS_CHIPSET_NOT_SUPPORTED: GpuP2PStatus.CHIPSET_NOT_SUPPORTED, nvml.GpuP2PStatus.P2P_STATUS_GPU_NOT_SUPPORTED: GpuP2PStatus.GPU_NOT_SUPPORTED, nvml.GpuP2PStatus.P2P_STATUS_IOH_TOPOLOGY_NOT_SUPPORTED: GpuP2PStatus.IOH_TOPOLOGY_NOT_SUPPORTED, nvml.GpuP2PStatus.P2P_STATUS_DISABLED_BY_REGKEY: GpuP2PStatus.DISABLED_BY_REGKEY, nvml.GpuP2PStatus.P2P_STATUS_NOT_SUPPORTED: GpuP2PStatus.NOT_SUPPORTED, nvml.GpuP2PStatus.P2P_STATUS_UNKNOWN: GpuP2PStatus.UNKNOWN}
_GPU_TOPOLOGY_LEVEL_MAPPING = {GpuTopologyLevel.INTERNAL: nvml.GpuTopologyLevel.TOPOLOGY_INTERNAL, GpuTopologyLevel.SINGLE: nvml.GpuTopologyLevel.TOPOLOGY_SINGLE, GpuTopologyLevel.MULTIPLE: nvml.GpuTopologyLevel.TOPOLOGY_MULTIPLE, GpuTopologyLevel.HOSTBRIDGE: nvml.GpuTopologyLevel.TOPOLOGY_HOSTBRIDGE, GpuTopologyLevel.NODE: nvml.GpuTopologyLevel.TOPOLOGY_NODE, GpuTopologyLevel.SYSTEM: nvml.GpuTopologyLevel.TOPOLOGY_SYSTEM}
_GPU_TOPOLOGY_LEVEL_INV_MAPPING = {v: k for k, v in _GPU_TOPOLOGY_LEVEL_MAPPING.items()}
__all__ = ['Device', 'get_p2p_status', 'get_topology_common_ancestor', 'NvlinkInfo']

def _unpack_bitmask(arr: object) -> list[int]:
    """
    Unpack a list of integers containing bitmasks.
    """

def get_topology_common_ancestor(device1: Device, device2: Device) -> GpuTopologyLevel:
    """
    Retrieve the common ancestor for two devices.

    For Linux only.

    Parameters
    ----------
    device1: :class:`Device`
        The first device.
    device2: :class:`Device`
        The second device.

    Returns
    -------
    :class:`GpuTopologyLevel`
        The common ancestor level of the two devices.
    """

def get_p2p_status(device1: Device, device2: Device, index: GpuP2PCapsIndex | str) -> GpuP2PStatus:
    """
    Retrieve the P2P status between two devices.

    Parameters
    ----------
    device1: :class:`Device`
        The first device.
    device2: :class:`Device`
        The second device.
    index: :class:`GpuP2PCapsIndex` | str
        The P2P capability index being looked for between ``device1`` and ``device2``.

    Returns
    -------
    :class:`GpuP2PStatus`
        The P2P status between the two devices.
    """