ytm._core.device_config.parse_device#

ytm._core.device_config.parse_device(device: str) → tuple[str, int]#

Parse a device string into its kind and number.

Parameters:
devicestr

"cpu", "cpu:N", "cuda" or "cuda:N". For cpu, N is the number of threads, at least 1, default 1. For cuda, N is the GPU id, at least 0, default 0.

Returns:
kind{“cpu”, “cuda”}

Device kind.

nint

Thread count for cpu, GPU id for cuda.

Raises:
ValueError

If the kind is unknown, or N is not an integer or out of range.