Utils

exception mosaic.utils.utils.MultiError(exc)[source]

Bases: Exception

add(exc)[source]
mosaic.utils.utils.cpu_count()[source]

Get the number of available cores in the node.

Returns:

Number of CPUs.

Return type:

int

mosaic.utils.utils.gpu_count()[source]

Get the number of available GPUs in the node.

Returns:

Number of GPUs.

Return type:

int

mosaic.utils.utils.memory_limit()[source]

Get the memory limit (in bytes) for this system.

Takes the minimum value from the following locations: - Total system host memory - Cgroups limit (if set) - RSS rlimit (if set)

Returns:

Memory limit.

Return type:

float

mosaic.utils.utils.memory_used(pid=None)[source]

Get the memory currently being used by the system.

Parameters:

pid (int, optional) – PID for which to get memory.

Returns:

Memory used.

Return type:

float

async mosaic.utils.utils.remote_sizeof(obj, seen=None, pending=False)[source]

Recursively finds size of remote objects.

Parameters:
  • obj (object) – Object to check size.

  • pending (bool) – Only count pending objects.

  • seen

Returns:

Size in bytes.

Return type:

float

mosaic.utils.utils.set_main_thread()[source]

Set current thread as main thread.

mosaic.utils.utils.sizeof(obj, seen=None)[source]

Recursively finds size of objects.

Parameters:
  • obj (object) – Object to check size.

  • seen

Returns:

Size in bytes.

Return type:

float