analogvnn.utils.is_cpu_cuda
#
Module Contents#
Classes#
CPUCuda is a class that can be used to get, check and set the device. |
Attributes#
The CPUCuda instance. |
- class analogvnn.utils.is_cpu_cuda.CPUCuda[source]#
CPUCuda is a class that can be used to get, check and set the device.
- Variables:
_device (torch.device) – The device.
device_name (str) – The name of the device.
- property device: torch.device[source]#
Get the device.
- Returns:
the device.
- Return type:
- property is_cpu: bool[source]#
Check if the device is cpu.
- Returns:
True if the device is cpu, False otherwise.
- Return type:
- property is_cuda: bool[source]#
Check if the device is cuda.
- Returns:
True if the device is cuda, False otherwise.
- Return type:
- property is_using_cuda: Tuple[torch.device, bool][source]#
Check if the device is cuda.
- Returns:
the device and True if the device is cuda, False otherwise.
- Return type:
- _device: torch.device[source]#
- set_device(device_name: Union[str, torch.device]) CPUCuda [source]#
Set the device to the given device name.
- Parameters:
device_name (Union[str, torch.device]) – the device name.
- Returns:
self
- Return type:
- get_module_device(module) torch.device [source]#
Get the device of the given module.
- Parameters:
module (torch.nn.Module) – the module.
- Returns:
the device of the module.
- Return type: