Closed thangld201 closed 6 months ago
@thangld201 I am not sure but here are some possible causes:
To eliminate these effects, can you measure the time between this lines? https://github.com/thu-coai/NAST/blob/ef765d412f6e9a2ebdcc7d62c99ec2e883d0e17a/styletransformer/seq2seq.py#L313-L324
@hzhwcmhf , I found that Line 334: predict_res.append(self.param.volatile.cls.predict_str(sents))
was the cause (took up 99% of the time). I will dive a bit more....not sure why this is slow...
@hzhwcmhf , I found that Line 334:
predict_res.append(self.param.volatile.cls.predict_str(sents))
was the cause (took up 99% of the time). I will dive a bit more....not sure why this is slow...
It runs a classifier. Maybe check whether this classifier is on gpu?
It runs a classifier. Maybe check whether this classifier is on gpu?
Yeah, you are right, self.param.volatile.cls.net
was on cpu.
In NAST/styletransformer/run_cls.py
, Line 47-69:
L47: parser.add_argument('--cuda', action="store_true", help='Use cuda (gpu).')
...
L69: args.cuda = "cuda" if cargs.cuda else "cpu"
since cargs
was parsed from Line 64 in NAST/styletransformer/main.py
i.e.
cls_param.args = run_cls.run("--dryrun", "--restore", args.clsrestore) # <----- do not have cuda flags
so I changed Line 64 to
cls_param.args = run_cls.run("--cuda", "--dryrun", "--restore", args.clsrestore)
And it worked! Validation now takes less than half a minute (Yelp)! Thank you!
I realized that validation was weirdly long. To show this, I changed Line 84-96 of
NAST/styletransformer/seq2seq.py
to the followings:And the logs show:
So validation alone runs 10x slower than training. Do you have any idea why ? @hzhwcmhf