Backend API

get_device(log_info=False, *, cuda_precision='bf16-mixed')

Detect the accelerator and the precision a trainer runs at on it.

Parameters:

Name Type Description Default
log_info bool

If True, log the Python, torch and GPU backend versions.

False
cuda_precision str

The precision on CUDA. train passes training.trainer.precision (spec 4.2); the default is the shipped bf16-mixed.

'bf16-mixed'

Returns:

Type Description
str

(device, precision, num_gpus). The device is cuda, mps or cpu. The

str

precision is cuda_precision on CUDA and 32-true everywhere else. num_gpus is

int

1 on MPS and 0 on CPU.