Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
lm-evaluation-harness
Commits
7f7b717d
Commit
7f7b717d
authored
Sep 28, 2021
by
Leo Gao
Browse files
gpt2: fix bad multi gpu behavior and typecheck inputs
parent
e037ef0a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
lm_eval/models/gpt2.py
lm_eval/models/gpt2.py
+7
-1
No files found.
lm_eval/models/gpt2.py
View file @
7f7b717d
...
@@ -15,6 +15,11 @@ class GPT2LM(LM):
...
@@ -15,6 +15,11 @@ class GPT2LM(LM):
def
__init__
(
self
,
device
=
'cuda'
,
pretrained
=
'gpt2'
,
batch_size
=
1
):
def
__init__
(
self
,
device
=
'cuda'
,
pretrained
=
'gpt2'
,
batch_size
=
1
):
super
().
__init__
()
super
().
__init__
()
assert
isinstance
(
device
,
str
)
assert
isinstance
(
pretrained
,
str
)
assert
isinstance
(
batch_size
,
int
)
if
device
:
if
device
:
self
.
device
=
torch
.
device
(
device
)
self
.
device
=
torch
.
device
(
device
)
else
:
else
:
...
@@ -37,7 +42,8 @@ class GPT2LM(LM):
...
@@ -37,7 +42,8 @@ class GPT2LM(LM):
gpus
=
torch
.
cuda
.
device_count
()
gpus
=
torch
.
cuda
.
device_count
()
batch_size_per_gpu
=
batch_size
# todo: adaptive batch size
batch_size_per_gpu
=
batch_size
# todo: adaptive batch size
self
.
batch_size
=
batch_size_per_gpu
*
gpus
# TODO: fix multi-gpu
self
.
batch_size
=
batch_size_per_gpu
# * gpus
# TODO: fix multi-gpu
# TODO: fix multi-gpu
# if gpus > 1:
# if gpus > 1:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment