Skip to content

Commit a742fe2

Browse files
bmccannsoumith
authored andcommitted
friendlier gpu options in translate
1 parent 1d0d15d commit a742fe2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

OpenNMT/translate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
help="""If verbose is set, will output the n_best
3737
decoded sentences""")
3838

39-
parser.add_argument('-gpu', type=int, default=7,
40-
help="Use CUDA")
39+
parser.add_argument('-gpu', type=int, default=-1,
40+
help="Device to run on")
4141

4242

4343

@@ -49,7 +49,7 @@ def reportScore(name, scoreTotal, wordsTotal):
4949

5050
def main():
5151
opt = parser.parse_args()
52-
opt.cuda = True
52+
opt.cuda = True if opt.gpu > -1
5353
torch.cuda.set_device(opt.gpu)
5454

5555
translator = onmt.Translator(opt)

0 commit comments

Comments
 (0)