NVIDIA Deep Learning Examples
NVIDIA Deep Learning Examples
ResNet50 v1.5 for PaddlePaddle
Resource
NVIDIA Deep Learning Examples
NVIDIA Deep Learning Examples
ResNet50 v1.5 for PaddlePaddle

With modified architecture and initialization this ResNet50 version gives ~0.5% better accuracy than original.

The performance measurements in this document were conducted at the time of publication and may not reflect the performance achieved from NVIDIA's latest software release. For the most up-to-date performance measurements, go to NVIDIA Data Center Deep Learning Product Performance.

Benchmarking

The following section shows how to run benchmarks measuring the model performance in training and inference modes.

Training performance benchmark

To benchmark training (A100 GPUs only for now), set --benchmark, --benchmark-steps and --benchmark-warmup-steps, then run training with --run-scope train_only. Refer to Command-line options.

Example:

# For 8 GPUs benchmark for AMP
python -m paddle.distributed.launch --gpus=0,1,2,3,4,5,6,7 train.py \
  --run-scope train_only \
  --amp \
  --scale-loss 128.0 \
  --use-dynamic-loss-scaling \
  --data-layout NHWC \
  --benchmark \
  --benchmark-steps 100 \
  --benchmark-warmup-steps 300

Benchmark will run 300 iterations for warmup and 100 iterations for benchmark, then save benchmark results in the --report-file file.

Inference performance benchmark

Benchmark

To benchmark evaluation (A100 GPUs only for now), set --benchmark, --benchmark-steps and --benchmark-warmup-steps, then run training with --run-scope eval_only. Refer to Command-line options.

Example:

# For 8 GPUs benchmark for AMP
python -m paddle.distributed.launch --gpus=0,1,2,3,4,5,6,7 train.py \
  --run-scope eval_only \
  --amp \
  --data-layout NHWC \
  --benchmark \
  --benchmark-steps 100 \
  --benchmark-warmup-steps 300

Benchmark will run 300 iterations for warmup and 100 iterations for benchmark, then save benchmark results in the --report-file file.

It is also allowed to set batch size for benchmark by adding --batch-size <batch_size> in launching commands.

# For 8 GPUs benchmark for AMP
python -m paddle.distributed.launch --gpus=0,1,2,3,4,5,6,7 train.py \
  --run-scope eval_only \
  --batch-size 32 \
  --amp \
  --data-layout NHWC \
  --benchmark \
  --benchmark-steps 100 \
  --benchmark-warmup-steps 300
Benchmark with TensorRT

To benchmark the inference performance with TensorRT on a specific batch size, run:

  • FP32 / TF32
python inference.py \
    --trt-inference-dir <path_to_exported_model> \
    --trt-precision FP32 \
    --batch-size <batch_size> \
    --benchmark-steps 1024 \
    --benchmark-warmup-steps 16
  • FP16
python inference.py \
    --trt-inference-dir <path_to_exported_model> \
    --trt-precision FP16 \
    --batch-size <batch_size>
    --benchmark-steps 1024 \
    --benchmark-warmup-steps 16

Note that arguments passed to inference.py should be the same with arguments used in training.

The benchmark uses the validation dataset by default, which should be put in --image-root/val. For the performance benchmark of the raw model, a synthetic dataset can be used. To use synthetic dataset, add --trt-use-synthat True as a command line option.

Results

Training accuracy results

Our results were obtained by running the applicable training script in the PaddlePaddle NGC container.

To achieve these same results, follow the steps in the Quick Start Guide.

Training accuracy: NVIDIA DGX A100 (8x A100 80GB)
EpochsMixed Precision Top1TF32 Top1
5075.96 +/- 0.0976.17 +/- 0.11
9076.93 +/- 0.1476.91 +/- 0.13
Example plots

The following images show the 90 epochs configuration on a DGX-A100.

ValidationLoss

ValidationTop1

ValidationTop5

Accuracy recovering of Automatic SParsity: NVIDIA DGX A100 (8x A100 80GB)
EpochsMixed Precision Top1 (Baseline)Mixed Precision+ASP Top1
9076.9276.72

Training performance results

Our results were obtained by running the applicable training script in the PaddlePaddle NGC container.

To achieve these same results, follow the steps in the Quick Start Guide.

Training performance: NVIDIA DGX A100 (8x A100 80GB)
GPUsThroughput - TF32Throughput - mixed precisionThroughput speedup (TF32 to mixed precision)TF32 ScalingMixed Precision ScalingMixed Precision Training Time (90E)TF32 Training Time (90E)
1993 img/s2711 img/s2.73 x1.0 x1.0 x~13 hours~40 hours
87955 img/s20267 img/s2.54 x8.01 x7.47 x~2 hours~4 hours
Training performance of Automatic SParsity: NVIDIA DGX A100 (8x A100 80GB)
GPUsThroughput - mixed precisionThroughput - mixed precision+ASPOverhead
12711 img/s2686 img/s1.0%
820267 img/s20144 img/s0.6%

Note that the train.py would enable CPU affinity binding to GPUs by default, that is designed and guaranteed being optimal for NVIDIA DGX-series. You could disable binding via launch train.py with --enable-cpu-affinity false.

Inference performance results

Inference performance: NVIDIA DGX A100 (1x A100 80GB)

Our results were obtained by running the applicable training script with --run-scope eval_only argument in the PaddlePaddle NGC container.

TF32 Inference Latency

Batch SizeAvg throughputAvg latency90% Latency95% Latency99% Latency
1138.90 img/s7.19 ms7.25 ms7.70 ms17.05 ms
2263.20 img/s7.59 ms7.61 ms8.27 ms18.17 ms
4442.47 img/s9.04 ms9.31 ms10.10 ms20.41 ms
8904.99 img/s8.83 ms9.27 ms10.08 ms18.16 ms
161738.12 img/s9.20 ms9.75 ms10.16 ms18.06 ms
322423.74 img/s13.20 ms16.09 ms18.10 ms28.01 ms
642890.31 img/s22.14 ms22.10 ms22.79 ms30.62 ms
1282676.88 img/s47.81 ms68.94 ms77.97 ms92.41 ms
2563283.94 img/s77.95 ms79.02 ms80.88 ms98.36 ms

Mixed Precision Inference Latency

Batch SizeAvg throughputAvg latency90% Latency95% Latency99% Latency
1127.12 img/s7.86 ms8.24 ms8.52 ms14.17 ms
2239.49 img/s8.35 ms9.08 ms9.78 ms9.89 ms
4519.19 img/s7.70 ms7.44 ms7.69 ms14.20 ms
8918.01 img/s8.71 ms8.39 ms9.08 ms21.23 ms
161795.41 img/s8.91 ms9.73 ms10.36 ms11.39 ms
323201.59 img/s9.99 ms12.04 ms15.29 ms23.23 ms
644919.89 img/s13.00 ms13.66 ms14.06 ms24.75 ms
1284361.36 img/s29.34 ms47.47 ms157.49 ms77.42 ms
2565742.03 img/s44.58 ms52.78 ms356.58 ms78.99 ms

Paddle-TRT performance results

Paddle-TRT performance: NVIDIA DGX A100 (1x A100 80GB)

Our results for Paddle-TRT were obtained by running the inference.py script on NVIDIA DGX A100 with (1x A100 80G) GPU.

TF32 Inference Latency

Batch SizeAvg throughputAvg latency90% Latency95% Latency99% Latency
1716.49 img/s1.40 ms1.96 ms2.20 ms3.01 ms
21219.98 img/s1.64 ms2.26 ms2.90 ms5.04 ms
41880.12 img/s2.13 ms3.39 ms4.44 ms7.32 ms
82404.10 img/s3.33 ms4.51 ms5.90 ms10.39 ms
163101.28 img/s5.16 ms7.06 ms9.13 ms15.18 ms
323294.11 img/s9.71 ms21.42 ms26.94 ms35.79 ms
644327.38 img/s14.79 ms25.59 ms30.45 ms45.34 ms
1284956.59 img/s25.82 ms33.74 ms40.36 ms56.06 ms
2565244.29 img/s48.81 ms62.11 ms67.56 ms88.38 ms

FP16 Inference Latency

Batch SizeAvg throughputAvg latency90% Latency95% Latency99% Latency
1860.90 img/s1.16 ms1.81 ms2.06 ms2.98 ms
21464.06 img/s1.37 ms2.13 ms2.73 ms4.76 ms
42246.24 img/s1.78 ms3.17 ms4.20 ms7.39 ms
82457.44 img/s3.25 ms4.35 ms5.50 ms9.98 ms
163928.83 img/s4.07 ms6.26 ms8.50 ms15.10 ms
323853.13 img/s8.30 ms19.87 ms25.51 ms34.99 ms
645581.89 img/s11.46 ms22.32 ms30.75 ms43.35 ms
1286846.77 img/s18.69 ms25.43 ms35.03 ms50.04 ms
2567481.19 img/s34.22 ms40.92 ms51.10 ms65.68 ms

Paddle-TRT performance: NVIDIA A30 (1x A30 24GB)

Our results for Paddle-TRT were obtained by running the inference.py script on NVIDIA A30 with (1x A30 24G) GPU.

TF32 Inference Latency

Batch SizeAvg throughputAvg latency90% Latency95% Latency99% Latency
1672.79 img/s1.49 ms2.01 ms2.29 ms3.04 ms
21041.47 img/s1.92 ms2.49 ms2.87 ms4.13 ms
41505.64 img/s2.66 ms3.43 ms4.06 ms6.85 ms
82001.13 img/s4.00 ms4.72 ms5.54 ms9.51 ms
162462.80 img/s6.50 ms7.71 ms9.32 ms15.54 ms
322474.34 img/s12.93 ms21.61 ms25.76 ms34.69 ms
642949.38 img/s21.70 ms29.58 ms34.63 ms47.11 ms
1283278.67 img/s39.04 ms43.34 ms52.72 ms66.78 ms
2563293.10 img/s77.74 ms90.51 ms99.71 ms110.80 ms

FP16 Inference Latency

Batch SizeAvg throughputAvg latency90% Latency95% Latency99% Latency
1804.56 img/s1.24 ms1.81 ms2.15 ms3.07 ms
21435.74 img/s1.39 ms2.05 ms2.48 ms3.86 ms
42169.87 img/s1.84 ms2.72 ms3.39 ms5.94 ms
82395.13 img/s3.34 ms4.46 ms5.11 ms9.49 ms
163779.82 img/s4.23 ms5.83 ms7.66 ms14.44 ms
323620.18 img/s8.84 ms17.90 ms22.31 ms30.91 ms
644592.08 img/s13.94 ms24.00 ms29.38 ms41.41 ms
1285064.06 img/s25.28 ms31.73 ms37.79 ms53.01 ms
2564774.61 img/s53.62 ms59.04 ms67.29 ms80.51 ms

Paddle-TRT performance: NVIDIA A10 (1x A10 24GB)

Our results for Paddle-TRT were obtained by running the inference.py script on NVIDIA A10 with (1x A10 24G) GPU.

TF32 Inference Latency

Batch SizeAvg throughputAvg latency90% Latency95% Latency99% Latency
1372.04 img/s2.69 ms3.64 ms4.20 ms5.28 ms
2615.93 img/s3.25 ms4.08 ms4.59 ms6.42 ms
41070.02 img/s3.74 ms3.90 ms4.35 ms7.48 ms
81396.88 img/s5.73 ms6.87 ms7.52 ms10.63 ms
161522.20 img/s10.51 ms12.73 ms13.84 ms17.84 ms
321674.39 img/s19.11 ms23.23 ms24.63 ms29.55 ms
641782.14 img/s35.91 ms41.84 ms44.53 ms48.94 ms
1281722.33 img/s74.32 ms85.37 ms89.27 ms94.85 ms
2561576.89 img/s162.34 ms181.01 ms185.92 ms194.42 ms

FP16 Inference Latency

Batch SizeAvg throughputAvg latency90% Latency95% Latency99% Latency
1365.38 img/s2.74 ms3.94 ms4.35 ms5.64 ms
2612.52 img/s3.26 ms4.34 ms4.80 ms6.97 ms
41018.15 img/s3.93 ms4.95 ms5.55 ms9.16 ms
81924.26 img/s4.16 ms5.44 ms6.20 ms11.89 ms
162477.49 img/s6.46 ms8.07 ms9.21 ms15.05 ms
322896.01 img/s11.05 ms13.56 ms15.32 ms21.76 ms
643165.27 img/s20.22 ms24.20 ms25.94 ms33.18 ms
1283176.46 img/s40.29 ms46.36 ms49.15 ms54.95 ms
2563110.01 img/s82.31 ms93.21 ms96.06 ms99.97 ms