Merge pull request #88 from stanford-oval/wip/no_grad

add torch.no_grad to kfserver
This commit is contained in:
jgd5 2021-02-04 13:34:18 -08:00 committed by GitHub
commit ca293b8814
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 60 additions and 60 deletions

View File

@ -64,6 +64,7 @@ class Server:
return NumericalizedExamples.collate_batches(all_features, self.numericalizer, device=self.device)
def handle_request(self, line):
with torch.no_grad():
if isinstance(line, dict):
request = line
else:
@ -169,7 +170,6 @@ class Server:
self.model.to(self.device)
self.model.eval()
with torch.no_grad():
if self.args.stdin:
self._run_stdin()
else: