unilab.utils.device

Functions

get_default_device()

Detect the best available device.

get_device_info_dict()

Collect static hardware metadata (chip, cores, GPU, memory) for run records.

get_device_info_line()

resolve_torch_device_alias(device, *[, default])

Resolve a cross-platform torch device alias to a concrete device string.

unilab.utils.device.get_default_device()[source]

Detect the best available device.

Return type:

str

unilab.utils.device.resolve_torch_device_alias(device, *, default='cpu')[source]

Resolve a cross-platform torch device alias to a concrete device string.

gpu is an abstract accelerator alias. cuda is also accepted on macOS/MPS for config portability and maps to mps when CUDA is absent. The function validates the resolved device and never silently falls back to CPU for unavailable accelerators.

Parameters:
Return type:

str

unilab.utils.device.get_device_info_dict()[source]

Collect static hardware metadata (chip, cores, GPU, memory) for run records.

Return type:

dict[str, str]

unilab.utils.device.get_device_info_line()[source]
Return type:

str