Skip to content

Commit

Permalink
Avoid error when executing benchmark util outside a git folder (#1691)
Browse files Browse the repository at this point in the history
  • Loading branch information
rasbt authored Aug 22, 2024
1 parent aaed893 commit 2ddf893
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions litgpt/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,9 +671,12 @@ def print_table(header, data):
print(markdown_table)

import subprocess
g_hash = subprocess.run(['git', 'rev-parse', '--short', 'HEAD'],
capture_output=True, text=True, check=True).stdout.strip()
print(f"Git Commit Hash: {g_hash}")
try:
g_hash = subprocess.run(['git', 'rev-parse', '--short', 'HEAD'],
capture_output=True, text=True, check=True).stdout.strip()
print(f"Git Commit Hash: {g_hash}")
except subprocess.CalledProcessError:
print("Git Commit Hash: N/A")
print(f"PyTorch version: {torch.__version__}")
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
print(f"Device: {device}\n")
Expand Down

0 comments on commit 2ddf893

Please sign in to comment.