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
12 changes: 6 additions & 6 deletions gpt_2_simple/gpt_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,15 +576,15 @@ def copy_checkpoint_to_gdrive(run_name='run1', copy_folder=False):
checkpoint_folder = os.path.join('checkpoint', run_name)

if copy_folder:
shutil.copytree(checkpoint_folder, "/content/drive/My Drive/" + checkpoint_folder)
shutil.copytree(checkpoint_folder, "/content/drive/MyDrive/" + checkpoint_folder)
else:
file_path = get_tarfile_name(checkpoint_folder)

# Reference: https://stackoverflow.com/a/17081026
with tarfile.open(file_path, 'w') as tar:
tar.add(checkpoint_folder)

shutil.copyfile(file_path, "/content/drive/My Drive/" + file_path)
shutil.copyfile(file_path, "/content/drive/MyDrive/" + file_path)


def copy_checkpoint_from_gdrive(run_name='run1', copy_folder=False):
Expand All @@ -594,11 +594,11 @@ def copy_checkpoint_from_gdrive(run_name='run1', copy_folder=False):
checkpoint_folder = os.path.join('checkpoint', run_name)

if copy_folder:
shutil.copytree("/content/drive/My Drive/" + checkpoint_folder, checkpoint_folder)
shutil.copytree("/content/drive/MyDrive/" + checkpoint_folder, checkpoint_folder)
else:
file_path = get_tarfile_name(checkpoint_folder)

shutil.copyfile("/content/drive/My Drive/" + file_path, file_path)
shutil.copyfile("/content/drive/MyDrive/" + file_path, file_path)

with tarfile.open(file_path, 'r') as tar:
tar.extractall()
Expand All @@ -608,14 +608,14 @@ def copy_file_to_gdrive(file_path):
"""Copies a file to a mounted Google Drive."""
is_mounted()

shutil.copyfile(file_path, "/content/drive/My Drive/" + file_path)
shutil.copyfile(file_path, "/content/drive/MyDrive/" + file_path)


def copy_file_from_gdrive(file_path):
"""Copies a file from a mounted Google Drive."""
is_mounted()

shutil.copyfile("/content/drive/My Drive/" + file_path, file_path)
shutil.copyfile("/content/drive/MyDrive/" + file_path, file_path)


def is_gpt2_downloaded(model_dir='models', model_name='124M'):
Expand Down