tf.estimator

时间:2017-12-23 01:14:52

标签: tensorflow grpc tensorflow-estimator

我在OpenStack上运行的Ubuntu 16.04上通过1.4运行TensorFlow pip。我按照TensorFlow线性模型教程here运行一个简单的逻辑回归模型。一切都在当地运行良好。我按照RunConfig()上的文档here在小型群集上运行模型。据我所知,分发预测估算器只需要设置适当的JSON环境变量。我这样做了如下:

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调用脚本:python tf_dist_example.py 0 chief和另一个窗口:python tf_dist_example.py 0 psworker-1上的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抱怨它们已经在使用中。此外,如果我创建一个更低级别的示例,手动创建ClusterSpecServer,那么主人和工作人员可以正常通信,一切都按预期工作。任何人都可以提供有关如何进一步调试或指出我哪里出错的建议吗?我确定对于发生的事情有一个简单的解释。如果有帮助,我可以添加来自gRPC的更多邮件。

1 个答案:

答案 0 :(得分:1)

如果其他人遇到此问题而发现此问题是因为他们也在使用grpc,当我遇到此问题时,问题是由于应用程序同时侦听了grpc端口和http端口。

我不小心将http端口配置为grpc端口,因此应用程序尝试使用相同的端口两次。