pararealml.utils package

Submodules

pararealml.utils.rand module

pararealml.utils.rand.set_random_seed(seed: int)[source]

Sets the Python, NumPy, and Tensorflow random seeds to the provided value.

Parameters:seed – the random seed value to use

pararealml.utils.tf module

pararealml.utils.tf.limit_visible_gpus()[source]

If there are GPUs available, it sets the GPU corresponding to the MPI rank of the process as the only device visible to Tensorflow.

pararealml.utils.tf.use_cpu()[source]

Ensures that Tensorflow does not use any GPUs.

pararealml.utils.tf.use_deterministic_ops()[source]

Ensures Tensorflow operations are deterministic.

pararealml.utils.time module

pararealml.utils.time.mpi_time(function_name: Optional[str] = None) → Callable[source]

Times the execution of the wrapped function using MPI, prints the execution time using the provided function name on the first rank, and returns the return value of the wrapped function along with the execution time.

Parameters:function_name – the name of the function
Returns:a function that returns the wrapped function
pararealml.utils.time.time(function_name: Optional[str] = None) → Callable[source]

Times the execution of the wrapped function, prints the execution time using the provided function name, and returns the return value of the wrapped function along with the execution time.

Parameters:function_name – the name of the function
Returns:a function that returns the wrapped function

Module contents