cuda.core.system.Device#

class cuda.core.system.Device(int index: int | None = None, uuid: bytes | str | None = None)#

Representation of a device.

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 cuda.core.Device.

Parameters:
  • index (int, optional) – Integer representing the CUDA device index to get a handle to.

  • uuid (bytes or str, optional) – UUID of a CUDA device to get a handle to.

Raises:

ValueError – If neither index nor uuid are specified or if both are specified.

Methods

__init__(*args, **kwargs)#
clear_field_values(self, list field_ids: list[int | tuple[int, int]]) None#

Clear multiple field values from the device.

Parameters:

field_ids (list of int or tuple of (int, int)) –

List of field IDs to clear.

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

classmethod get_all_devices(cls) Iterable[Device]#

Query the available device instances.

Returns:

An iterator over available devices.

Return type:

Iterator of Device

get_field_values(self, list 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 FieldValues container.

To confirm that there are no exceptions in the entire container, call FieldValues.validate().

Parameters:

field_ids (list of int or tuple of (int, int)) –

List of field IDs to query.

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

Returns:

Container of field values corresponding to the requested field IDs.

Return type:

FieldValues

Attributes

architecture#

DeviceArchitecture

Device architecture. For example, a Tesla V100 will report DeviceArchitecture.name == "Volta", and RTX A6000 will report DeviceArchitecture.name == "Ampere". If the device returns an architecture that is unknown to NVML then DeviceArchitecture.name == "Unknown" is reported, whereas an architecture that is unknown to cuda.core.system is reported as DeviceArchitecture.name == "Unlisted".

Type:

Device.architecture

bar1_memory_info#

BAR1MemoryInfo

Get information about BAR1 memory.

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).

Type:

Device.bar1_memory_info

cpu_affinity#

list[int]

Get a list containing the CPU indices to which the GPU is directly connected.

Examples

>>> Device(index=0).cpu_affinity
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]
Type:

Device.cpu_affinity

cuda_compute_capability#

tuple[int, int]

CUDA compute capability of the device, e.g.: (7, 0) for a Tesla V100.

Returns a tuple (major, minor).

Type:

Device.cuda_compute_capability

handle#

int

Type:

Device.handle

memory_info#

MemoryInfo

Object with memory information.

Type:

Device.memory_info

name#

str

Name of the device, e.g.: “Tesla V100-SXM2-32GB”

Type:

Device.name

pci_info#

PciInfo

The PCI attributes of this device.

Type:

Device.pci_info

serial#

str

Retrieves the globally unique board serial number associated with this device’s board.

Type:

Device.serial

uuid#

str

Retrieves the globally unique immutable UUID associated with this device, as a 5 part hexadecimal string, that augments the immutable, board serial identifier.

Type:

Device.uuid