Skip to content

Commit

Permalink
Fix mkdir conflict in save_inference_model (PaddlePaddle#14285)
Browse files Browse the repository at this point in the history
*  fix mkdir conflict

test=develop
  • Loading branch information
seiriosPlus committed Nov 7, 2018
1 parent 6449fae commit e564eb3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions python/paddle/fluid/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def is_persistable(var):
Examples:
.. code-block:: python
param = fluid.default_main_program().global_block().var('fc.w')
param = fluid.default_main_program().global_block().var('fc.b')
res = fluid.io.is_persistable(param)
"""
if var.desc.type() == core.VarDesc.VarType.FEED_MINIBATCH or \
Expand Down Expand Up @@ -625,8 +625,13 @@ def save_inference_model(dirname,
main_program._distributed_lookup_table,
main_program._endpoints)

if not os.path.isdir(dirname):
# when a pserver and a trainer running on the same machine, mkdir may conflict
try:
os.makedirs(dirname)
except OSError as e:
if e.errno != errno.EEXIST:
raise

if model_filename is not None:
model_basename = os.path.basename(model_filename)
else:
Expand Down

0 comments on commit e564eb3

Please sign in to comment.