Skip to content

Device#

lit.sdk.device #

This module provides utilities for retrieving and processing GPU information on a system with NVIDIA GPUs. It includes functionality to fetch GPU details, such as name, bus ID, temperature, utilization, and more, using the nvidia-smi command-line tool.

GPU dataclass #

Represents a GPU.

device instance-attribute #

The device number.

memory_percent instance-attribute #

The memory utilization percentage.

name instance-attribute #

The official product name of the GPU.

pci_bus_id instance-attribute #

The PCI bus ID of the GPU.

pid instance-attribute #

The ID of the first (if any) process found running on the GPU.

pstate instance-attribute #

The current performance state for the GPU. States range from P0 (maximum performance) to P12 (minimum performance).

temperature instance-attribute #

The current temperature of the GPU in degrees Celsius.

total_memory instance-attribute #

The total memory of the GPU in MB.

user instance-attribute #

The owner of the first (if any) process running on the GPU.

utilization_percent instance-attribute #

The GPU compute utilization percentage.

vbios_version instance-attribute #

The VBIOS version of the GPU board.

get_gpus() #

Retrieves a list of NVIDIA GPUs from the system.

This function uses nvidia-smi to query GPU information and ps to gather process information.

Returns:

Type Description
list[GPU]

A list of GPU objects, each representing a NVIDIA GPU on the system.

Examples:

>>> get_gpus()
[GPU(name='NVIDIA GeForce RTX 4090', pci_bus_id='00000000:01:00.0', vbios_version='94.02.71.80.74', temperature=39, utilization_percent=2, memory_percent=9, total_memory=12884, pstate='P8', device=0, pid=2284, user='root')]