- To start, we load TensorFlow and define our two local workers with a configuration dictionary file (ports 2222 and 2223) as follows:
import tensorflow as tf # Cluster for 2 local workers (tasks 0 and 1): cluster = tf.train.ClusterSpec({'local': ['localhost:2222', 'localhost:2223']})
- Now, we join the two workers into the server and label them with the following task numbers:
server = tf.train.Server(cluster, job_name="local", task_index=0) server = tf.train.Server(cluster, job_name="local", task_index=1)
- Now we will have each worker complete a task. The first worker will initialize two matrices (each one will be 25 by 25). The second worker will find the sum of all of the elements. Then, we will auto-assign the sum of ...