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.

__doc__ = '\nThis module provides utilities for retrieving and processing GPU information on a system\nwith NVIDIA GPUs. It includes functionality to fetch GPU details, such as name, bus ID,\ntemperature, utilization, and more, using the `nvidia-smi` command-line tool.\n' module #

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

__file__ = '/opt/lit-platform/lit-lib/src/lit/sdk/device.cpython-312-x86_64-linux-gnu.so' module #

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

__name__ = 'lit.sdk.device' module #

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

__package__ = 'lit.sdk' module #

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

__test__ = {'get_gpus (line 44)': "\n Retrieves a list of NVIDIA GPUs from the system.\n\n This function uses `nvidia-smi` to query GPU information and `ps` to gather process information.\n\n Returns:\n (list[GPU]): A list of GPU objects, each representing a NVIDIA GPU on the system.\n\n Examples:\n >>> get_gpus()\n [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')]\n "} module #

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

GPU #

Represents a GPU.

__annotations__ = {'name': 'str', 'pci_bus_id': 'str', 'vbios_version': 'str', 'temperature': 'int', 'utilization_percent': 'int', 'memory_percent': 'int', 'total_memory': 'int', 'pstate': 'str', 'device': 'int', 'pid': 'int', 'user': 'str'} class #

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

__dataclass_fields__ = {'name': Field(name='name',type='str',default=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,default_factory=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'pci_bus_id': Field(name='pci_bus_id',type='str',default=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,default_factory=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'vbios_version': Field(name='vbios_version',type='str',default=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,default_factory=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'temperature': Field(name='temperature',type='int',default=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,default_factory=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'utilization_percent': Field(name='utilization_percent',type='int',default=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,default_factory=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'memory_percent': Field(name='memory_percent',type='int',default=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,default_factory=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'total_memory': Field(name='total_memory',type='int',default=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,default_factory=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'pstate': Field(name='pstate',type='str',default=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,default_factory=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'device': Field(name='device',type='int',default=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,default_factory=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'pid': Field(name='pid',type='int',default=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,default_factory=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'user': Field(name='user',type='str',default=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,default_factory=<dataclasses._MISSING_TYPE object at 0x7fef887f4b30>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)} class #

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

__doc__ = 'Represents a GPU.' class #

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

__match_args__ = ('name', 'pci_bus_id', 'vbios_version', 'temperature', 'utilization_percent', 'memory_percent', 'total_memory', 'pstate', 'device', 'pid', 'user') class #

Built-in immutable sequence.

If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.

If the argument is a tuple, the return value is the same object.

__module__ = 'lit.sdk.device' class #

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

__weakref__ property #

list of weak references to the object

LitDeviceError #

Bases: lit.sdk.errors.LitError

A custom exception class for Lit device errors.

__annotations__ = {} class #

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

__doc__ = 'A custom exception class for Lit device errors.' class #

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

__module__ = 'lit.sdk.errors' class #

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

__init__(*args, code=None) method descriptor #

Initializes a new instance of LitDeviceError.

Parameters:

Name Type Description Default
*args object

Variable number of arguments to pass to the base class constructor.

required
code int | None

The error code. Defaults to None.

None

lit_error_handler(error_type=LitError) method descriptor #

A decorator function that catches and re-raises exceptions with a custom error type.

Parameters:

Name Type Description Default
error_type Type[LitError]

The type of exception to raise. Defaults to LitError.

LitError

Returns:

Type Description
Callable

A wrapper function that catches exceptions and raises the specified error type.

Examples:

>>> @lit_error_handler()
... def raises_error():
...     assert False
...
>>> raises_error()
Traceback (most recent call last):
File "/opt/lit/src/lit/sdk/errors.py", line 130, in wrapper
File "<stdin>", line 3, in raises_error
AssertionError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/lit/src/lit/sdk/errors.py", line 132, in wrapper
lit.sdk.errors.LitError: An error occurred in function 'raises_error'