From 4d680d2d58cc29719c21588d99c0c2d96036a521 Mon Sep 17 00:00:00 2001 From: Mike Walmsley Date: Thu, 23 Nov 2023 17:34:22 -0500 Subject: [PATCH] fix race condition --- zoobot/pytorch/training/train_with_pytorch_lightning.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zoobot/pytorch/training/train_with_pytorch_lightning.py b/zoobot/pytorch/training/train_with_pytorch_lightning.py index 50c5759a..daa5ae9b 100644 --- a/zoobot/pytorch/training/train_with_pytorch_lightning.py +++ b/zoobot/pytorch/training/train_with_pytorch_lightning.py @@ -114,7 +114,10 @@ def train_default_zoobot_from_scratch( assert save_dir is not None if not os.path.isdir(save_dir): - os.mkdir(save_dir) + try: + os.mkdir(save_dir) + except FileExistsError(): + pass # another gpu process may have just made it logging.info(f'Saving to {save_dir}') if color: