Skip to content

Commit

Permalink
support setting max batch/workspace size when convert to trt (#692)
Browse files Browse the repository at this point in the history
  • Loading branch information
wwqgtxx committed Sep 14, 2021
1 parent c7c5ccf commit db7aa57
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tools/trt.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def make_parser():
help="pls input your expriment description file",
)
parser.add_argument("-c", "--ckpt", default=None, type=str, help="ckpt path")
parser.add_argument("-w", '--workspace', type=int, default=32, help='max workspace size in detect')
parser.add_argument("-b", '--batch', type=int, default=1, help='max batch size in detect')
return parser


Expand Down Expand Up @@ -59,7 +61,8 @@ def main():
[x],
fp16_mode=True,
log_level=trt.Logger.INFO,
max_workspace_size=(1 << 32),
max_workspace_size=(1 << args.workspace),
max_batch_size=args.batch,
)
torch.save(model_trt.state_dict(), os.path.join(file_name, "model_trt.pth"))
logger.info("Converted TensorRT model done.")
Expand Down

0 comments on commit db7aa57

Please sign in to comment.