def load_config():
"""Returns ClusterConfig object. Config contains task spec and cluster spec in dictionary-like form as below
# {"task": {"index": 0, "type": "worker"}, "cluster": {"worker": ["localhost:24724"], "ps": ["localhost:15960"]}}
"""
# old way that doesn't work for sparse format
# if 'TF_CONFIG' not in os.environ:
# # try loading encoded version
# if 'TF_CONFIG_BASE16' in os.environ:
# tf_config_str = base64.b16decode(os.environ['TF_CONFIG_BASE16'])
# tf_config_str = tf_config_str.decode('ascii')
# os.environ['TF_CONFIG'] = tf_config_str
# del os.environ['TF_CONFIG_BASE16']
# else:
# assert False, "Must specify TF_CONFIG or TF_CONFIG_BASE16"
# from tensorflow.contrib.learn.python.learn.estimators.run_config import ClusterConfig
config = MyClusterConfig()
config_dict = pickle.loads(base64.b16decode(os.environ["TF_PICKLE_BASE16"]))
config.task_type = config_dict["task"]["type"]
config.task_id = config_dict["task"]["index"]
config.cluster_spec = config_dict["cluster"]
return config
评论列表
文章目录