gpu_stats package
The GPU Stats Package handles collection of information from connected GPUs
gpu_stats._base module
Parent class for obtaining Stats for various GPU/TPU backends. All GPU Stats should inherit
from the _GPUStats
class contained here.
- class lib.gpu_stats._base.BiggestGPUInfo(card_id: int, device: str, free: float, total: float)
Bases:
object
Dataclass for holding GPU Information about the card with most available VRAM.
- card_id
Integer representing the index of the GPU device.
- Type:
int
- device
The name of the device
- Type:
str
- free
The amount of available VRAM on the GPU
- Type:
float
- total
the total amount of VRAM on the GPU
- Type:
float
- card_id: int
- device: str
- free: float
- total: float
- class lib.gpu_stats._base.GPUInfo(vram: list[int], vram_free: list[int], driver: str, devices: list[str], devices_active: list[int])
Bases:
object
Dataclass for storing information about the available GPUs on the system.
Attributes:
- vram: list[int]
List of integers representing the total VRAM available on each GPU, in MB.
- vram_free: list[int]
List of integers representing the free VRAM available on each GPU, in MB.
- driver: str
String representing the driver version being used for the GPUs.
- devices: list[str]
List of strings representing the names of each GPU device.
- devices_active: list[int]
List of integers representing the indices of the active GPU devices.
- devices: list[str]
- devices_active: list[int]
- driver: str
- vram: list[int]
- vram_free: list[int]
- lib.gpu_stats._base.set_exclude_devices(devices: list[int]) None
Add any explicitly selected GPU devices to the global list of devices to be excluded from use by Faceswap.
- Parameters:
devices (list[int]) – list of GPU device indices to exclude
Example
>>> set_exclude_devices([0, 1]) # Exclude the first two GPU devices
gpu_stats.apple_silicon module
Collects and returns Information on available Apple Silicon SoCs in Apple Macs.
- 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 Tensorflow are used to pull as much useful information as possible.
- Parameters:
log (bool, optional) – 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 toTrue
. Default:True
gpu_stats.amd module
gpu_stats.cpu module
Dummy functions for running faceswap on CPU.
- class lib.gpu_stats.cpu.CPUStats(log: bool = True)
Bases:
_GPUStats
Holds information and statistics about the CPU on the currently running system.
Notes
The information held here is not useful, but _GPUStats is dynamically imported depending on the backend used, so we need to make sure this class is available for Faceswap run on the CPU Backend.
The base
_GPUStats
handles the dummying in of information when no GPU is detected.- Parameters:
log (bool, optional) – 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 toTrue
. Default:True
gpu_stats.directml module
gpu_stats.nvidia_apple module
Collects and returns Information on available Nvidia GPUs connected to Apple Macs.
- class lib.gpu_stats.nvidia_apple.NvidiaAppleStats(log: bool = True)
Bases:
_GPUStats
Holds information and statistics about Nvidia GPU(s) available on the currently running Apple system.
Notes
PyNvx is used for hooking in to Nvidia’s Machine Learning Library and allows for pulling fairly extensive statistics for Apple based Nvidia GPUs
- Parameters:
log (bool, optional) – 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 toTrue
. Default:True
gpu_stats.nvidia module
Collects and returns Information on available Nvidia GPUs.
- 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, optional) – 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 toTrue
. Default:True
gpu_stats.rocm module
Collects and returns Information about connected AMD GPUs for ROCm using sysfs and from modinfo
As no ROCm compatible hardware was available for testing, this just returns information on all AMD GPUs discovered on the system regardless of ROCm compatibility.
It is a good starting point but may need to be refined over time
- class lib.gpu_stats.rocm.ROCm(log: bool = True)
Bases:
_GPUStats
Holds information and statistics about GPUs connected using sysfs
- Parameters:
log (bool, optional) – 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 toTrue
. Default:True