Skip to content

Commit a00f965

Browse files
cccclaifacebook-github-bot
authored andcommitted
add cpu device to run eval on cpu (#3133)
Summary: `HFLM` from `lm_eval` can take cpu device. https://github.com/EleutherAI/lm-evaluation-harness/blob/main/lm_eval/models/huggingface.py#L95 Currently running `eval_llama` fails on cpu Reviewed By: lucylq Differential Revision: D56313161
1 parent 3db0362 commit a00f965

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

examples/models/llama2/eval_llama_lib.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,11 @@ def __init__(
4242
tokenizer: Union[SentencePieceTokenizer, Tiktoken],
4343
max_seq_length: Optional[int] = None,
4444
):
45-
super().__init__()
45+
device = "cuda" if torch.cuda.is_available() else "cpu"
46+
super().__init__(device=device)
4647
self._model = model
4748
self._tokenizer = tokenizer
48-
self._device = (
49-
torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
50-
)
49+
self._device = torch.device(device)
5150
self._max_seq_length = 2048 if max_seq_length is None else max_seq_length
5251

5352
@property

0 commit comments

Comments
 (0)