You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# No previous checkpoint size to estimate, do nothing.
832
+
return
833
+
834
+
def_mb_size(num_bytes):
835
+
returnf"{num_bytes/1024/1024:.2f} MB"
836
+
837
+
try:
838
+
stat=shutil.disk_usage(output_dir)
839
+
free_bytes=stat.free
840
+
needed_bytes=checkpoint_size*warn_steps_ahead
841
+
842
+
log_rank_0(
843
+
f"Disk space info: free={_mb_size(free_bytes)}, last_checkpoint_size={_mb_size(checkpoint_size)} (output_dir={output_dir})"
844
+
)
845
+
iffree_bytes<needed_bytes:
846
+
log_rank_0(
847
+
f"Estimated free disk space ({_mb_size(free_bytes)}) is less than the estimated size of the next {warn_steps_ahead} checkpoints ({_mb_size(needed_bytes)}). "
848
+
"The next checkpoint(s) may fail due to insufficient disk space.",
849
+
level=logging.WARNING,
850
+
)
851
+
exceptExceptionase:
852
+
log_rank_0(
853
+
f"Could not check disk space after checkpoint: {e}",
854
+
level=logging.ERROR,
855
+
)
856
+
857
+
800
858
defsave_checkpoint(
801
859
args,
802
860
accelerator: Accelerator,
@@ -827,6 +885,15 @@ def save_checkpoint(
827
885
samples_seen=samples_seen,
828
886
)
829
887
888
+
# Track checkpoint size and warn if disk space is low
0 commit comments