diff --git a/python/paddle/fluid/executor.py b/python/paddle/fluid/executor.py index bf9754ce2bf92a18e08b81b1843811b2a51382a9..1bca5bb3a14657c409960db2d10ed90936d11de5 100644 --- a/python/paddle/fluid/executor.py +++ b/python/paddle/fluid/executor.py @@ -758,7 +758,7 @@ class Executor(object): def _dump_debug_info(self, program=None, trainer=None): with open(str(id(program)) + "_train_desc.prototxt", "w") as fout: - fout.write(trainer._desc()) + fout.write(str(trainer)) if program._fleet_opt: with open("fleet_desc.prototxt", "w") as fout: fout.write(str(program._fleet_opt["fleet_desc"])) diff --git a/python/paddle/fluid/trainer_desc.py b/python/paddle/fluid/trainer_desc.py index 806d09895ad1e7ff0b09516d3798e21c580dde35..a37ae6dea114cfe15883a6eaf98361c35cec3372 100644 --- a/python/paddle/fluid/trainer_desc.py +++ b/python/paddle/fluid/trainer_desc.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import sys +from os import path __all__ = ['TrainerDesc', 'MultiTrainer', 'DistMultiTrainer', 'PipelineTrainer'] @@ -23,6 +25,11 @@ class TrainerDesc(object): with open(proto_file, 'r') as f: text_format.Parse(f.read(), self.proto_desc) ''' + # Workaround for relative import in protobuf under python3 + # TODO: should be fixed + cur_path = path.dirname(__file__) + sys.path.append(cur_path) + sys.path.append(cur_path + "/proto") from proto import trainer_desc_pb2 self.proto_desc = trainer_desc_pb2.TrainerDesc() import multiprocessing as mp @@ -68,6 +75,9 @@ class TrainerDesc(object): from google.protobuf import text_format return self.proto_desc.SerializeToString() + def __str__(self): + return str(self.proto_desc) + class MultiTrainer(TrainerDesc): def __init__(self):