Skip to content

Commit e564eb3

Browse files
authored
Fix mkdir conflict in save_inference_model (#14285)
* fix mkdir conflict test=develop
1 parent 6449fae commit e564eb3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

python/paddle/fluid/io.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def is_persistable(var):
6565
Examples:
6666
.. code-block:: python
6767
68-
param = fluid.default_main_program().global_block().var('fc.w')
68+
param = fluid.default_main_program().global_block().var('fc.b')
6969
res = fluid.io.is_persistable(param)
7070
"""
7171
if var.desc.type() == core.VarDesc.VarType.FEED_MINIBATCH or \
@@ -625,8 +625,13 @@ def save_inference_model(dirname,
625625
main_program._distributed_lookup_table,
626626
main_program._endpoints)
627627

628-
if not os.path.isdir(dirname):
628+
# when a pserver and a trainer running on the same machine, mkdir may conflict
629+
try:
629630
os.makedirs(dirname)
631+
except OSError as e:
632+
if e.errno != errno.EEXIST:
633+
raise
634+
630635
if model_filename is not None:
631636
model_basename = os.path.basename(model_filename)
632637
else:

0 commit comments

Comments
 (0)