pytorch_bert_large.py 1013 Bytes
Newer Older
1
2
3
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

4
5
6
7
8
9
"""Model benchmark example for bert-large.

Commands to run:
  python3 examples/benchmarks/pytorch_bert_large.py (Single GPU)
  python3 -m torch.distributed.launch --nproc_per_node=8 examples/benchmarks/pytorch_bert_large.py (Distributed)
"""
10

11
from superbench.benchmarks import Framework, BenchmarkRegistry
12
13
14
15
from superbench.common.utils import logger

if __name__ == '__main__':
    # Create context for bert-large benchmark and run it for 120 * 2 seconds.
16
    context = BenchmarkRegistry.create_benchmark_context(
17
18
19
20
21
        'bert-large',
        parameters='--batch_size=1 --duration=120 --seq_len=512 --precision=float32 --run_count=2',
        framework=Framework.PYTORCH
    )

22
23
24
25
26
    benchmark = BenchmarkRegistry.launch_benchmark(context)
    if benchmark:
        logger.info(
            'benchmark: {}, return code: {}, result: {}'.format(
                benchmark.name, benchmark.return_code, benchmark.result
27
            )
28
        )