Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
2ef5e0de
Commit
2ef5e0de
authored
Jun 18, 2019
by
thomwolf
Browse files
switch to pytorch DistributedDataParallel
parent
9ce37af9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
examples/run_squad.py
examples/run_squad.py
+5
-5
No files found.
examples/run_squad.py
View file @
2ef5e0de
...
@@ -902,12 +902,12 @@ def main():
...
@@ -902,12 +902,12 @@ def main():
model
.
half
()
model
.
half
()
model
.
to
(
device
)
model
.
to
(
device
)
if
args
.
local_rank
!=
-
1
:
if
args
.
local_rank
!=
-
1
:
try
:
#
try:
from
apex.parallel
import
DistributedDataParallel
as
DDP
#
from apex.parallel import DistributedDataParallel as DDP
except
ImportError
:
#
except ImportError:
raise
ImportError
(
"Please install apex from https://www.github.com/nvidia/apex to use distributed and fp16 training."
)
#
raise ImportError("Please install apex from https://www.github.com/nvidia/apex to use distributed and fp16 training.")
model
=
DDP
(
model
)
model
=
torch
.
nn
.
parallel
.
DistributedDataParallel
(
model
)
elif
n_gpu
>
1
:
elif
n_gpu
>
1
:
model
=
torch
.
nn
.
DataParallel
(
model
)
model
=
torch
.
nn
.
DataParallel
(
model
)
...
...
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