tf.distribute.cluster_resolver.SlurmClusterResolver

View source on GitHub

ClusterResolver for system with Slurm workload manager.

Inherits From: ClusterResolver

tf.distribute.cluster_resolver.SlurmClusterResolver(
    jobs, port_base=8888, gpus_per_node=1, gpus_per_task=1, tasks_per_node=None,
    auto_set_gpu=True, rpc_layer='grpc'
)

This is an implementation of cluster resolvers for Slurm clusters. This allows the specification of jobs and task counts, number of tasks per node, number of GPUs on each node and number of GPUs for each task. It retrieves system attributes by Slurm environment variables, resolves allocated computing node names, constructs a cluster and returns a ClusterResolver object which can be use for distributed TensorFlow.

Args:

Attributes:

Raises:

Methods

cluster_spec

View source

cluster_spec()

Returns a ClusterSpec object based on the latest instance group info.

This returns a ClusterSpec object for use based on information from the specified initialization parameters and Slurm environment variables. The cluster specification is resolved each time this function is called. The resolver extract hostnames of nodes by scontrol and pack tasks in that order until a node a has number of tasks that is equal to specification. GPUs on nodes are allocated to tasks by specification through setting CUDA_VISIBLE_DEVICES environment variable.

Returns:

A ClusterSpec containing host information retrieved from Slurm's environment variables.

get_task_info

View source

get_task_info()

Returns job name and task_id for the process which calls this.

This returns the job name and task index for the process which calls this function according to its rank and cluster specification. The job name and task index are set after a cluster is constructed by cluster_spec otherwise defaults to None.

Returns:

A string specifying job name the process belongs to and an integner specifying the task index the process belongs to in that job.

master

View source

master(
    task_type=None, task_id=None, rpc_layer=None
)

Returns the master string for connecting to a TensorFlow master.

Args:

Returns:

A connection string for connecting to a TensorFlow master.

num_accelerators

View source

num_accelerators(
    task_type=None, task_id=None, config_proto=None
)

Returns the number of accelerator cores per worker.

This returns the number of accelerator cores (such as GPUs and TPUs) available per worker.

Optionally, we allow callers to specify the task_type, and task_id, for if they want to target a specific TensorFlow process to query the number of accelerators. This is to support heterogenous environments, where the number of accelerators cores per host is different.

Args:

Returns:

A map of accelerator types to number of cores.