我正在运行通过在 OpenStack 上运行的 Ubuntu 16.04 上1.4
安装的 TensorFlow。我按照此处pip
的 TensorFlow 线性模型教程运行了一个简单的逻辑回归模型。在本地运行一切正常。我正在按照此处的文档在小型集群上运行模型。据我了解,分发罐装估算器只是设置适当的 JSON 环境变量的问题。我这样做如下:RunConfig()
rank = int(argv[1])
instance_type = argv[2]
...
cluster = {'chief': ['master:2222'],
'ps': ['master:2223'],
'worker' : ['worker-1:2222']}
os.environ['TF_CONFIG']= json.dumps(
{'cluster': cluster,
'task': {'type': instance_type, 'index': rank}})
...
indep_vars = build_vars()
config = tf.estimator.RunConfig()
lr = tf.estimator.LinearClassifier(model_dir=None,
config = config,
feature_columns=indep_vars)
train_spec = tf.estimator.TrainSpec(
input_fn=lambda: input_fn_logit(data_path, 1, BATCH_SIZE),
max_steps=10)
eval_spec = tf.estimator.EvalSpec(
input_fn=lambda: input_fn_logit(data_path, 1, BATCH_SIZE),
steps=1)
tf.estimator.train_and_evaluate(lr, train_spec, eval_spec)
然后,我从master
as:python tf_dist_example.py 0 chief
和另一个窗口中调用脚本:并python tf_dist_example.py 0 ps
在worker-1
as:上调用脚本python tf_dist_example.py 0 worker
。
chief
实例抛出错误:tensorflow.python.framework.errors_impl.UnknownError: Could not start gRPC server
设置后export GRPC_VERBOSITY=DEBUG
,报错gRPC
:
{"created":"@1513990687.907885617","description":"No address added out of total 1 resolved","file":"external/grpc/src/core/ext/transport/chttp2/server/chttp2_server.c","file_line":245,"referenced_errors":
[{"created":"@1513990687.907882392","description":"Failed to add any wildcard listeners","file":"external/grpc/src/core/lib/iomgr/tcp_server_posix.c","file_line":338,"referenced_errors":
[{"created":"@1513990687.907869775","description":"Unable to configure socket","fd":7,"file":"external/grpc/src/core/lib/iomgr/tcp_server_utils_posix_common.c","file_line":200,"referenced_errors":
[{"created":"@1513990687.907859814","description":"OS Error","errno":98,"file":"external/grpc/src/core/lib/iomgr/tcp_server_utils_posix_common.c","file_line":173,"os_error":"Address already in use","syscall":"bind"}]},
{"created":"@1513990687.907881598","description":"Unable to configure socket","fd":7,"file":"external/grpc/src/core/lib/iomgr/tcp_server_utils_posix_common.c","file_line":200,"referenced_errors":
[{"created":"@1513990687.907879042","description":"OS Error","errno":98,"file":"external/grpc/src/core/lib/iomgr/tcp_server_utils_posix_common.c","file_line":173,"os_error":"Address already in use","syscall":"bind"}]}]}]}
错误似乎很明显:gRPC 尝试连接的端口已在使用中。但是,我验证netstat -tulpn
没有其他进程正在使用这些端口中的任何一个,所以我不明白为什么 gRPC 抱怨它们已经在使用中。此外,如果我创建一个更底层的示例来手动创建一个ClusterSpec
and Server
,那么 master 和 worker 可以正常通信并且一切都按预期工作。任何人都可以提供有关如何进一步调试或指出我哪里出错的任何建议吗?我相信对于发生的事情有一个简单的解释。gRPC
如果有帮助,我可以包含更多消息。