NvidiaStats

class lib.gpu_stats.nvidia.NvidiaStats(log: bool = True)

Bases: _GPUStats

Holds information and statistics about Nvidia GPU(s) available on the currently running system.

Notes

PyNVML is used for hooking in to Nvidia’s Machine Learning Library and allows for pulling fairly extensive statistics for Nvidia GPUs

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)

Exclude GPU devices from being used by Faceswap.

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

Exclude GPU devices from being used by Faceswap. Sets the CUDA_VISIBLE_DEVICES environment variable. This must be called before Torch/Keras are imported

Parameters:
  • excluded (The GPU device IDS to be)

  • devices (list[int])

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

Exclude GPU devices from being used by Faceswap. Sets the CUDA_VISIBLE_DEVICES environment variable. This must be called before Torch/Keras are imported

Parameters:
  • excluded (The GPU device IDS to be)

  • devices (list[int])

Return type:

None