analogvnn.utils.is_cpu_cuda#

Module Contents#

Classes#

CPUCuda

CPUCuda is a class that can be used to get, check and set the device.

Attributes#

is_cpu_cuda

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:

torch.device

property is_cpu: bool[source]#

Check if the device is cpu.

Returns:

True if the device is cpu, False otherwise.

Return type:

bool

property is_cuda: bool[source]#

Check if the device is cuda.

Returns:

True if the device is cuda, False otherwise.

Return type:

bool

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:

tuple

_device: torch.device[source]#
device_name: str[source]#
use_cpu() CPUCuda[source]#

Use cpu.

Returns:

self

Return type:

CPUCuda

use_cuda_if_available() CPUCuda[source]#

Use cuda if available.

Returns:

self

Return type:

CPUCuda

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:

CPUCuda

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:

torch.device

analogvnn.utils.is_cpu_cuda.is_cpu_cuda: CPUCuda[source]#

The CPUCuda instance.

Type:

CPUCuda