未验证 提交 e564eb34 编写于 作者: T tangwei12 提交者: GitHub

Fix mkdir conflict in save_inference_model (#14285)

*  fix mkdir conflict

test=develop
上级 6449faec
......@@ -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 \
......@@ -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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册