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
OpenDAS
Fairseq
Commits
bcdc27dc
Commit
bcdc27dc
authored
Apr 12, 2018
by
Myle Ott
Browse files
No more magical --fp16
parent
745d5fbd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
2 deletions
+3
-2
fairseq/options.py
fairseq/options.py
+1
-2
singleprocess_train.py
singleprocess_train.py
+2
-0
No files found.
fairseq/options.py
View file @
bcdc27dc
...
@@ -155,8 +155,7 @@ def add_optimization_args(parser):
...
@@ -155,8 +155,7 @@ def add_optimization_args(parser):
' (default is to normalize by number of tokens)'
)
' (default is to normalize by number of tokens)'
)
group
.
add_argument
(
'--update-freq'
,
default
=
'1'
,
metavar
=
'N'
,
group
.
add_argument
(
'--update-freq'
,
default
=
'1'
,
metavar
=
'N'
,
help
=
'update parameters every N_i batches, when in epoch i'
)
help
=
'update parameters every N_i batches, when in epoch i'
)
has_tensor_cores
=
torch
.
cuda
.
device_count
()
>
0
and
torch
.
cuda
.
get_device_capability
(
0
)[
0
]
>=
7
group
.
add_argument
(
'--fp16'
,
action
=
'store_true'
,
group
.
add_argument
(
'--fp16'
,
action
=
'store_true'
,
default
=
has_tensor_cores
,
help
=
'use FP16 during training'
)
help
=
'use FP16 during training'
)
# Optimizer definitions can be found under fairseq/optim/
# Optimizer definitions can be found under fairseq/optim/
...
...
singleprocess_train.py
View file @
bcdc27dc
...
@@ -52,6 +52,8 @@ def main(args):
...
@@ -52,6 +52,8 @@ def main(args):
if
args
.
fp16
:
if
args
.
fp16
:
trainer
=
FP16Trainer
(
args
,
model
,
criterion
)
trainer
=
FP16Trainer
(
args
,
model
,
criterion
)
else
:
else
:
if
torch
.
cuda
.
get_device_capability
(
0
)[
0
]
>=
7
:
print
(
'| NOTICE: your device may support faster training with --fp16'
)
trainer
=
Trainer
(
args
,
model
,
criterion
)
trainer
=
Trainer
(
args
,
model
,
criterion
)
print
(
'| training on {} GPUs'
.
format
(
args
.
distributed_world_size
))
print
(
'| training on {} GPUs'
.
format
(
args
.
distributed_world_size
))
print
(
'| max tokens per GPU = {} and max sentences per GPU = {}'
.
format
(
print
(
'| max tokens per GPU = {} and max sentences per GPU = {}'
.
format
(
...
...
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