AppleSiliconStats

class lib.gpu_stats.apple_silicon.AppleSiliconStats(log: bool = True)

Bases: _GPUStats

Holds information and statistics about Apple Silicon SoC(s) available on the currently running Apple system.

Notes

Apple Silicon is a bit different from other backends, as it does not have a dedicated GPU with it’s own dedicated VRAM, rather the RAM is shared with the CPU and GPU. A combination of psutil and torch are used to pull as much useful information as possible.

Parameters:

log (bool) – Whether the class should output information to the logger. There may be occasions where the logger has not yet been set up when this class is queried. Attempting to log in these instances will raise an error. If GPU stats are being queried prior to the logger being available then this parameter should be set to False. Otherwise set to True. Default: True

Attributes Summary

cli_devices

name text string for each GPU

device_count

The number of GPU devices discovered on the system.

exclude_all_devices

True if all GPU devices have been explicitly disabled otherwise False

sys_info

The GPU Stats that are required for system information logging

Methods Summary

exclude_devices(devices)

Apple-Silicon does not support excluding devices

get_card_most_free()

Obtain statistics for the GPU with the most available free VRAM.

Attributes Documentation

cli_devices

name text string for each GPU

Type:

Formatted index

device_count

The number of GPU devices discovered on the system.

exclude_all_devices

True if all GPU devices have been explicitly disabled otherwise False

sys_info

The GPU Stats that are required for system information logging

Methods Documentation

exclude_devices(devices: list[int]) None

Apple-Silicon does not support excluding devices

Parameters:

devices (list[int]) – The GPU device IDS to be excluded

Return type:

None

get_card_most_free() BiggestGPUInfo

Obtain statistics for the GPU with the most available free VRAM.

Returns:

  • If a GPU is not detected then the card_id is returned as -1 and the amount

  • of free and total RAM available is fixed to 2048 Megabytes.

Return type:

BiggestGPUInfo

exclude_devices(devices: list[int]) None

Apple-Silicon does not support excluding devices

Parameters:

devices (list[int]) – The GPU device IDS to be excluded

Return type:

None