Skip to content

Commit 9d032dd

Browse files
authored
Fix evaluation if device not specified (#1344)
1 parent daad8f9 commit 9d032dd

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

litgpt/eval/evaluate.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ def convert_and_evaluate(
7272
)
7373
return
7474

75+
if device is None:
76+
device = "cuda" if torch.cuda.is_available() else "cpu"
77+
7578
checkpoint_dir = Path(checkpoint_dir)
7679

7780
if out_dir is None:

tests/test_evaluate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_evaluate_script(tmp_path, monkeypatch):
3939
fn_kwargs = dict(
4040
checkpoint_dir=tmp_path,
4141
out_dir=tmp_path / "out_dir",
42-
device="cpu",
42+
device=None,
4343
dtype=torch.float32,
4444
limit=5,
4545
tasks="mathqa"

0 commit comments

Comments
 (0)