cuda.bindings.nvml.device_get_handle_by_index_v2#
- cuda.bindings.nvml.device_get_handle_by_index_v2(unsigned int index) intptr_t#
Acquire the handle for a particular device, based on its index.
For all products. Valid indices are derived from the
accessibleDevicescount returned bydevice_get_count_v2(). For example, ifaccessibleDevicesis 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 UUID. Seedevice_get_handle_by_uuid()anddevice_get_handle_by_pci_bus_id_v2(). Note: The NVML index may not correlate with other APIs, such as the CUDA device index. Starting from NVML 5, this API causes NVML to initialize the target GPU NVML may initialize additional GPUs if:.The target GPU is an SLI slave.
Note: New nvmlDeviceGetCount_v2 (default in NVML 5.319) returns count of all devices in the system even if nvmlDeviceGetHandleByIndex_v2 returns NVML_ERROR_NO_PERMISSION for such device. Update your code to handle this error, or use NVML 4.304 or older nvml header file. For backward binary compatibility reasons _v1 version of the API is still present in the shared library. Old _v1 version of nvmlDeviceGetCount doesn’t count devices that NVML has no permission to talk to. This means that nvmlDeviceGetHandleByIndex_v2 and _v1 can return different devices for the same index. If you don’t touch macros that map old (_v1) versions to _v2 versions at the top of the file you don’t need to worry about that.
- Parameters:
index (unsigned int) – The index of the target GPU, >= 0 and <
accessibleDevices.- Returns:
Reference in which to return the device handle.
- Return type:
intptr_t
See also
nvmlDeviceGetHandleByIndex_v2