Avoid race condition in creating checkpoint directories (#530)
* Avoid race condition in creating checkpoint directories In multi-GPU training, several processes run the code that creates checkpoint dirs. This fix avoids a probably rare situation (but it happened to me) where another process created a dir between the `exists` check and the `makedirs` call. * Remove the now unneeded check for dir existence
This commit is contained in:
parent
c1ecca418e
commit
539d7bcb44
|
@ -198,8 +198,7 @@ class ModelCheckpoint(Callback):
|
||||||
self.monitor = monitor
|
self.monitor = monitor
|
||||||
self.verbose = verbose
|
self.verbose = verbose
|
||||||
self.filepath = filepath
|
self.filepath = filepath
|
||||||
if not os.path.exists(filepath):
|
os.makedirs(filepath, exist_ok=True)
|
||||||
os.makedirs(filepath)
|
|
||||||
self.save_top_k = save_top_k
|
self.save_top_k = save_top_k
|
||||||
self.save_weights_only = save_weights_only
|
self.save_weights_only = save_weights_only
|
||||||
self.period = period
|
self.period = period
|
||||||
|
|
Loading…
Reference in New Issue