봐 내가 쓴 :그래프 간 복제의 분산 텐서 흐름? 코드에서
import tensorflow as tf
tf.flags.DEFINE_string('job_name', 'ps', 'worker or ps')
tf.flags.DEFINE_integer('task_index', 0, 'task id')
FLAGS = tf.flags.FLAGS
host = '127.0.0.1:'
cluster = {"ps": [host+'2222'],
"worker": [host+'2223', host+'2224']}
clusterspec = tf.train.ClusterSpec(cluster)
server = tf.train.Server(cluster,
job_name=FLAGS.job_name,
task_index=FLAGS.task_index)
def print_fn():
print('job_name: %s, task_index: %d' % (FLAGS.job_name, FLAGS.task_index))
if FLAGS.job_name == 'ps':
server.join()
elif FLAGS.job_name == 'worker':
with tf.device(tf.train.replica_device_setter(
worker_device="/job:worker/task:%d" % FLAGS.task_index,
cluster=cluster)):
a = tf.Variable(tf.zeros([]), name='a')
b = tf.Variable(tf.zeros([]), name='b')
op = tf.add(a, b)
print(a.device)
print(b.device)
print(op.device)
print(tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES))
print_fn()
나는 cmd
에서 python distributed_replicas.py --job_name=worker --task_index=0
실행되지만 이전 python distributed_replicas.py --job_name=ps --task_index=0
를 실행하지 프로그램도 작동합니다. a.device
과 b.device
은 모두 /job:ps/task:0
이지만 ps server
은 시작되지 않습니다. a
및 b
은 ps server
에 어떻게 저장됩니까? 그리고 tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES)
에는 a
과 b
이라는 변수가 포함되어 있습니다. 이는 /job:worker/task:0
에 a
과 b
이 생성되었지만 기기가 /job:ps/task:0
인데 무엇이 문제입니까? a
및 b
은 어디에 있습니까?
? 모든 '작업자 서버'의 그래프가 분할되는 것을 의미합니까? 모든 작업자 서버가 수신 노드를 유지하고 모든 작업자 서버가 ps 서버에서 동일한 매개 변수를 수신한다는 것을 의미합니까? – gaussclb
일반적으로 Master (세션 생성시 클라이언트가 연결된 서버)는 분할 그래프를 작성하여 다른 서버로 전송합니다 (서버는 새 Session 또는 tf.train.Server로 생성됩니다). – xldrx
PS 아키텍처를 사용하는 경우 모든 작업자는 정방향 패스의 시작 부분에있는 하나 또는 여러 PS의 데이터를 읽는 Rec Op가 있으며 Backward 패스 중에 PS로 업데이트를 다시 보내려면 Send Op가 있습니다. – xldrx