Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion composer/callbacks/checkpoint_saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,13 @@ def __init__(

is_remote_folder = backend != ''
if is_remote_folder: # If uploading to a remote path, use a temporary directory to save local checkpoints.
local_folder = os.path.join(tempfile.mkdtemp(), local_folder)
root_temp_folder = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is already how mkdtemp works? https://docs.python.org/3/library/tempfile.html#tempfile.mkdtemp. The first place it should look to decide the tmpdir folder is whatever is specified by the TMPDIR env var.

if os.environ.get('TMPDIR') is not None:
root_temp_folder = os.environ.get('TMPDIR')
elif os.path.exists('/local_disk0/'): # Probably we are on MLR, so we have to use /local_disk0
root_temp_folder = '/local_disk0/temp'
os.makedirs(root_temp_folder, exist_ok=True)
local_folder = os.path.join(tempfile.mkdtemp(prefix=root_temp_folder), local_folder)

filename = str(filename)
remote_file_name = str(remote_file_name) if remote_file_name is not None else None
Expand Down
Loading