CUDAAccelerator

class lightning.pytorch.accelerators.CUDAAccelerator

Bases: Accelerator

Accelerator for NVIDIA CUDA devices.

static auto_device_count()

Get the devices when set to auto.

Return type:

int

get_device_stats(device)

Gets stats for the given GPU device.

Parameters:

device (Union[device, str, int]) – GPU device for which to get stats

Return type:

dict[str, Any]

Returns:

A dictionary mapping the metrics to their values.

Raises:

FileNotFoundError – If nvidia-smi installation not found

static get_parallel_devices(devices)

Gets parallel devices for the Accelerator.

Return type:

list[device]

static is_available()

Detect if the hardware is available.

Return type:

bool

static name()

The name of the accelerator.

Return type:

str

static parse_devices(devices)

Accelerator device parsing logic.

Return type:

Optional[list[int]]

classmethod register_accelerators(accelerator_registry)

Register the accelerator with the registry.

Return type:

None

setup(trainer)

Called by the Trainer to set up the accelerator before the model starts running on the device.

Parameters:

trainer (Trainer) – the trainer instance

Return type:

None

setup_device(device)
Raises:

MisconfigurationException – If the selected device is not GPU.

Return type:

None

teardown()

Clean up any state created by the accelerator.

Return type:

None