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

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 the training performance on a specific batch size, run:

  • For 1 GPU

    • FP32 / TF32

      python ./main.py --mode=training_benchmark --warmup_steps 200 --batch_size <batch size> --data_dir=<path to imagenet> --results_dir=<path to results directory>

    • AMP

      python ./main.py --mode=training_benchmark --amp --warmup_steps 200 --batch_size <batch size> --data_dir=<path to imagenet> --results_dir=<path to results directory>

  • For multiple GPUs

    • FP32 / TF32

      mpiexec --allow-run-as-root --bind-to socket -np <num_gpus> python ./main.py --mode=training_benchmark --batch_size <batch size> --data_dir=<path to imagenet> --results_dir=<path to results directory>

    • AMP

      mpiexec --allow-run-as-root --bind-to socket -np <num_gpus> python ./main.py --mode=training_benchmark --amp --batch_size <batch size> --data_dir=<path to imagenet> --results_dir=<path to results directory>

Each of these scripts runs 200 warm-up iterations and measures the first epoch.

To control warmup and benchmark length, use the --warmup_steps, --num_iter and --iter_unit flags. Features like XLA or DALI can be controlled with --xla and --dali flags. For proper throughput reporting the value of --num_iter must be greater than --warmup_steps value. Suggested batch sizes for training are 256 for mixed precision training and 128 for single precision training per single V100 16 GB.

If no --data_dir=<path to imagenet> flag is specified then the benchmarks will use a synthetic dataset. The resolution of synthetic images used can be controlled with --synthetic_data_size flag.

Inference performance benchmark

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

  • FP32 / TF32

python ./main.py --mode=inference_benchmark --warmup_steps 20 --num_iter 100 --iter_unit batch --batch_size <batch size> --data_dir=<path to imagenet> --results_dir=<path to results directory>

  • AMP

python ./main.py --mode=inference_benchmark --amp --warmup_steps 20 --num_iter 100 --iter_unit batch --batch_size <batch size> --data_dir=<path to imagenet> --results_dir=<path to results directory>

By default, each of these scripts runs 20 warm-up iterations and measures the next 80 iterations. To control warm-up and benchmark length, use the --warmup_steps, --num_iter and --iter_unit flags. If no --data_dir=<path to imagenet> flag is specified then the benchmarks will use a synthetic dataset.

The benchmark can be automated with the inference_benchmark.sh script provided in resnet50v1.5, by simply running: bash ./resnet50v1.5/inference_benchmark.sh <data dir> <data idx dir>

The <data dir> parameter refers to the input data directory (by default /data/tfrecords inside the container). By default, the benchmark tests the following configurations: FP32, AMP, AMP + XLA with different batch sizes. When the optional directory with the DALI index files <data idx dir> is specified, the benchmark executes an additional DALI + AMP + XLA configuration. For proper throughput reporting the value of --num_iter must be greater than --warmup_steps value.

For performance benchmark of raw model, synthetic dataset can be used. To use synthetic dataset, use --synthetic_data_size flag instead of --data_dir to specify input image size.

Results

The following sections provide details on how we achieved our performance and accuracy in training and inference.

Training accuracy results

Training accuracy: NVIDIA DGX A100 (8x A100 40GB)

Our results were obtained by running the /resnet50v1.5/training/DGXA100_RN50_{PRECISION}_90E.sh training script in the TensorFlow 20.06-tf1-py3 NGC container NGC container on NVIDIA DGX A100 (8x A100 40GB) GPUs.

EpochsBatch Size / GPUAccuracy - TF32 (top1)Accuracy - mixed precision (top1)
9025677.0176.93
Training accuracy: NVIDIA DGX-1 (8x V100 16G)

Our results were obtained by running the /resnet50v1.5/training/DGX1_RN50_{PRECISION}_{EPOCHS}E.sh training script in the TensorFlow 20.06-tf1-py3 NGC container NGC container on NVIDIA DGX-1 with (8x V100 16G) GPUs.

EpochsBatch Size / GPUAccuracy - FP32Accuracy - mixed precision
90128 (FP32) / 256 (AMP)77.0176.99
250128 (FP32) / 256 (AMP)78.3478.35

Example training loss plot

TrainingLoss

Training performance results

Training performance: NVIDIA DGX A100 (8x A100 40GB)

Our results were obtained by running the resnet50v1.5/training/training_perf.sh benchmark script in the TensorFlow 20.06-tf1-py3 NGC container NGC container on NVIDIA DGX A100 (8x A100 40GB) GPUs. Performance numbers (in images per second) were averaged over an entire training epoch.

GPUsBatch Size / GPUThroughput - TF32 + XLAThroughput - mixed precision + XLAThroughput speedup (TF32 - mixed precision)Weak scaling - TF32 + XLAWeak scaling - mixed precision + XLA
1256909 img/s2375 img/s2.60x1.00x1.00x
82567000 img/s17400 img/s2.48x7.70x7.32x
Training performance: NVIDIA DGX-1 (8x V100 16G)

Our results were obtained by running the resnet50v1.5/training/training_perf.sh benchmark script in the TensorFlow 20.06-tf1-py3 NGC container NGC container on NVIDIA DGX-1 with (8x V100 16G) GPUs. Performance numbers (in images per second) were averaged over an entire training epoch.

GPUsBatch Size / GPUThroughput - FP32 + XLAThroughput - mixed precision + XLAThroughput speedup (FP32 - mixed precision)Weak scaling - FP32 + XLAWeak scaling - mixed precision + XLA
1128 (FP32) / 256 (AMP)412 img/s1270 img/s3.08x1.00x1.00x
8128 (FP32) / 256 (AMP)3170 img/s9510 img/s3.00x7.69x7.48x
Training performance: NVIDIA DGX-2 (16x V100 32G)

Our results were obtained by running the resnet50v1.5/training/training_perf.sh benchmark script in the TensorFlow 20.06-tf1-py3 NGC container NGC container on NVIDIA DGX-2 with (16x V100 32G) GPUs. Performance numbers (in images per second) were averaged over an entire training epoch.

GPUsBatch Size / GPUThroughput - FP32 + XLAThroughput - mixed precision + XLAThroughput speedup (FP32 - mixed precision)Weak scaling - FP32 + XLAWeak scaling - mixed precision + XLA
1128 (FP32) / 256 (AMP)432 img/s1300 img/s3.01x1.00x1.00x
16128 (FP32) / 256 (AMP)6500 img/s17250 img/s2.65x15.05x13.27x

Training Time for 90 Epochs

Training time: NVIDIA DGX A100 (8x A100 40GB)

Our results were estimated based on the training performance results on NVIDIA DGX A100 with (8x A100 40G) GPUs.

GPUsTime to train - mixed precision + XLATime to train - TF32 + XLA
1~18h~40h
8~2h~5h
Training time: NVIDIA DGX-1 (8x V100 16G)

Our results were estimated based on the training performance results on NVIDIA DGX-1 with (8x V100 16G) GPUs.

GPUsTime to train - mixed precision + XLATime to train - FP32 + XLA
1~25h~77h
8~3.5h~10h
Training time: NVIDIA DGX-2 (16x V100 32G)

Our results were estimated based on the training performance results on NVIDIA DGX-2 with (16x V100 32G) GPUs.

GPUsTime to train - mixed precision + XLATime to train - FP32 + XLA
1~25h~74h
16~2h~5h

Inference performance results

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

Our results were obtained by running the inference_benchmark.sh inferencing benchmarking script in the TensorFlow 20.06-tf1-py3 NGC container NGC container on NVIDIA DGX A100 with (1x A100 40G) GPU.

TF32 Inference Latency

Batch SizeAvg throughputAvg latency90% Latency95% Latency99% Latency
1191.23 img/s5.26 ms5.29 ms5.31 ms5.42 ms
2376.83 img/s5.34 ms5.36 ms5.39 ms5.56 ms
4601.12 img/s6.65 ms6.80 ms6.93 ms7.05 ms
8963.86 img/s8.31 ms8.63 ms8.80 ms9.17 ms
161361.58 img/s11.82 ms12.04 ms12.15 ms12.44 ms
321602.09 img/s19.99 ms20.48 ms20.74 ms21.36 ms
641793.81 img/s35.82 ms37.22 ms37.43 ms37.84 ms
1281876.22 img/s68.23 ms69.60 ms70.08 ms70.70 ms
2561911.96 img/s133.90 ms135.16 ms135.59 ms136.49 ms

TF32 Inference Latency + XLA

Batch SizeAvg throughputAvg latency90% Latency95% Latency99% Latency
1158.67 img/s6.34 ms6.39 ms6.46 ms7.16 ms
2321.83 img/s6.24 ms6.29 ms6.34 ms6.39 ms
4574.28 img/s7.01 ms7.03 ms7.06 ms7.14 ms
81021.20 img/s7.84 ms8.00 ms8.08 ms8.28 ms
161515.79 img/s10.56 ms10.88 ms10.98 ms11.22 ms
321945.44 img/s16.46 ms16.78 ms16.96 ms17.49 ms
642313.13 img/s27.81 ms28.68 ms29.10 ms30.33 ms
1282449.88 img/s52.27 ms54.00 ms54.43 ms56.85 ms
2562548.87 img/s100.45 ms102.34 ms103.04 ms104.81 ms

Mixed Precision Inference Latency

Batch SizeAvg throughputAvg latency90% Latency95% Latency99% Latency
1223.35 img/s4.51 ms4.50 ms4.52 ms4.76 ms
2435.51 img/s4.63 ms4.62 ms4.64 ms4.76 ms
4882.00 img/s4.63 ms4.60 ms4.71 ms5.36 ms
81503.24 img/s5.40 ms5.50 ms5.59 ms5.78 ms
161903.58 img/s8.47 ms8.67 ms8.77 ms9.14 ms
321974.01 img/s16.23 ms16.65 ms16.96 ms17.98 ms
643570.46 img/s18.14 ms18.26 ms18.43 ms19.35 ms
1283474.94 img/s37.86 ms44.09 ms55.30 ms66.90 ms
2563229.32 img/s81.02 ms96.21 ms105.67 ms126.31 ms

Mixed Precision Inference Latency + XLA

Batch SizeAvg throughputAvg latency90% Latency95% Latency99% Latency
1174.68 img/s5.76 ms5.81 ms5.95 ms6.13 ms
2323.90 img/s6.21 ms6.26 ms6.31 ms6.64 ms
4639.75 img/s6.25 ms6.45 ms6.55 ms6.79 ms
81215.50 img/s6.59 ms6.94 ms7.03 ms7.25 ms
162219.96 img/s7.29 ms7.45 ms7.57 ms8.09 ms
322363.70 img/s13.70 ms13.91 ms14.08 ms14.64 ms
643940.95 img/s18.76 ms26.58 ms35.41 ms59.06 ms
1283274.01 img/s41.70 ms52.19 ms61.14 ms78.68 ms
2563676.14 img/s71.67 ms82.36 ms88.53 ms108.18 ms
Inference performance: NVIDIA DGX-1 (1x V100 16G)

Our results were obtained by running the inference_benchmark.sh inferencing benchmarking script in the TensorFlow 20.06-tf1-py3 NGC container NGC container on NVIDIA DGX-1 with (1x V100 16G) GPU.

FP32 Inference Latency

Batch SizeAvg throughputAvg latency90% Latency95% Latency99% Latency
1173.35 img/s5.79 ms5.90 ms5.95 ms6.04 ms
2303.65 img/s6.61 ms6.80 ms6.87 ms7.01 ms
4562.35 img/s7.12 ms7.32 ms7.42 ms7.69 ms
8783.24 img/s10.22 ms10.37 ms10.44 ms10.60 ms
161003.10 img/s15.99 ms16.07 ms16.12 ms16.29 ms
321140.12 img/s28.19 ms28.27 ms28.38 ms28.54 ms
641252.06 img/s51.12 ms51.82 ms52.75 ms53.45 ms
1281324.91 img/s96.61 ms97.02 ms97.25 ms99.08 ms
2561348.52 img/s189.85 ms191.16 ms191.77 ms192.47 ms

Mixed Precision Inference Latency

Batch SizeAvg throughputAvg latency90% Latency95% Latency99% Latency
1237.35 img/s4.25 ms4.39 ms4.54 ms5.30 ms
2464.94 img/s4.32 ms4.63 ms4.83 ms5.52 ms
4942.44 img/s4.26 ms4.55 ms4.74 ms5.45 ms
81454.93 img/s5.57 ms5.73 ms5.91 ms6.51 ms
162003.75 img/s8.13 ms8.19 ms8.29 ms8.50 ms
322356.17 img/s13.69 ms13.82 ms13.92 ms14.26 ms
642706.11 img/s23.86 ms23.82 ms23.89 ms24.10 ms
1282770.61 img/s47.04 ms49.36 ms62.43 ms90.05 ms
2562742.14 img/s94.67 ms108.02 ms119.34 ms145.55 ms

Mixed Precision Inference Latency + XLA

Batch SizeAvg throughputAvg latency90% Latency95% Latency99% Latency
1162.95 img/s6.16 ms6.28 ms6.34 ms6.50 ms
2335.63 img/s5.96 ms6.10 ms6.14 ms6.25 ms
4637.72 img/s6.30 ms6.53 ms7.17 ms8.10 ms
81153.92 img/s7.03 ms7.97 ms8.22 ms9.00 ms
161906.52 img/s8.64 ms9.51 ms9.88 ms10.47 ms
322492.78 img/s12.84 ms13.06 ms13.13 ms13.24 ms
642910.05 img/s22.66 ms21.82 ms24.71 ms48.61 ms
1282964.31 img/s45.25 ms59.30 ms71.42 ms98.72 ms
2562898.12 img/s90.53 ms106.12 ms118.12 ms150.78 ms
Inference performance: NVIDIA DGX-2 (1x V100 32G)

Our results were obtained by running the inference_benchmark.sh inferencing benchmarking script in the TensorFlow 20.06-tf1-py3 NGC container NGC container on NVIDIA DGX-2 with (1x V100 32G) GPU.

FP32 Inference Latency

Batch SizeAvg throughputAvg latency90% Latency95% Latency99% Latency
1187.41 img/s5.374 ms5.61 ms5.70 ms6.33 ms
2339.52 img/s5.901 ms6.16 ms6.29 ms6.53 ms
4577.50 img/s6.940 ms7.07 ms7.24 ms7.99 ms
8821.15 img/s9.751 ms9.99 ms10.15 ms10.80 ms
161055.64 img/s15.209 ms15.26 ms15.30 ms16.14 ms
321195.74 img/s26.772 ms26.93 ms26.98 ms27.80 ms
641313.83 img/s48.796 ms48.99 ms49.72 ms51.83 ms
1281372.58 img/s93.262 ms93.90 ms94.97 ms96.57 ms
2561414.99 img/s180.923 ms181.65 ms181.92 ms183.37 ms

Mixed Precision Inference Latency

Batch SizeAvg throughputAvg latency90% Latency95% Latency99% Latency
1289.89 img/s3.50 ms3.81 ms3.90 ms4.19 ms
2606.27 img/s3.38 ms3.56 ms3.76 ms4.25 ms
4982.92 img/s4.09 ms4.42 ms4.53 ms4.81 ms
81553.34 img/s5.22 ms5.31 ms5.50 ms6.74 ms
162091.27 img/s7.82 ms7.77 ms7.82 ms8.77 ms
322457.61 img/s13.14 ms13.15 ms13.21 ms13.37 ms
642746.11 img/s23.31 ms23.50 ms23.56 ms24.31 ms
1282937.20 img/s43.58 ms43.76 ms43.82 ms44.37 ms
2563009.83 img/s85.06 ms86.23 ms87.37 ms88.67 ms

Mixed Precision Inference Latency + XLA

Batch SizeAvg throughputAvg latency90% Latency95% Latency99% Latency
1240.66 img/s4.22 ms4.59 ms4.69 ms4.84 ms
2428.60 img/s4.70 ms5.11 ms5.44 ms6.01 ms
4945.38 img/s4.26 ms4.35 ms4.42 ms4.74 ms
81518.66 img/s5.33 ms5.50 ms5.63 ms5.88 ms
162091.66 img/s7.83 ms7.74 ms7.79 ms8.88 ms
322604.17 img/s12.40 ms12.45 ms12.51 ms12.61 ms
643101.15 img/s20.64 ms20.93 ms21.00 ms21.17 ms
1283408.72 img/s37.55 ms37.93 ms38.05 ms38.53 ms
2563633.85 img/s70.85 ms70.93 ms71.12 ms71.45 ms
Inference performance: NVIDIA T4 (1x T4 16G)

Our results were obtained by running the inference_benchmark.sh inferencing benchmarking script in the TensorFlow 20.06-tf1-py3 NGC container NGC container on NVIDIA T4 with (1x T4 16G) GPU.

FP32 Inference Latency

Batch SizeAvg throughputAvg latency90% Latency95% Latency99% Latency
1136.44 img/s7.34 ms7.43 ms7.47 ms7.54 ms
2215.38 img/s9.29 ms9.42 ms9.46 ms9.59 ms
4289.29 img/s13.83 ms14.08 ms14.16 ms14.40 ms
8341.77 img/s23.41 ms23.79 ms23.86 ms24.11 ms
16394.36 img/s40.58 ms40.87 ms40.98 ms41.41 ms
32414.66 img/s77.18 ms78.05 ms78.29 ms78.67 ms
64424.42 img/s150.82 ms152.99 ms153.44 ms154.34 ms
128429.83 img/s297.82 ms301.09 ms301.60 ms302.51 ms
256425.72 img/s601.37 ms605.74 ms606.47 ms608.74 ms

Mixed Precision Inference Latency

Batch SizeAvg throughputAvg latency90% Latency95% Latency99% Latency
1211.04 img/s4.77 ms5.05 ms5.08 ms5.15 ms
2381.23 img/s5.27 ms5.40 ms5.45 ms5.52 ms
4593.13 img/s6.75 ms6.89 ms6.956 ms7.02 ms
8791.12 img/s10.16 ms10.35 ms10.43 ms10.68 ms
16914.26 img/s17.55 ms17.80 ms17,89 ms18.19 ms
32972.36 img/s32.92 ms33.33 ms33.46 ms33.61 ms
64991.39 img/s64.56 ms65.62 ms65.92 ms66.35 ms
128995.81 img/s128.55 ms130.03 ms130.37 ms131.08 ms
256993.39 img/s257.71 ms259.26 ms259.62 ms260.36 ms

Mixed Precision Inference Latency + XLA

Batch SizeAvg throughputAvg latency90% Latency95% Latency99% Latency
1167.01 img/s6.01 ms6.12 ms6.14 ms6.18 ms
2333.67 img/s6.03 ms6.11 ms6.15 ms6.23 ms
4605.94 img/s6.63 ms6.79 ms6.86 ms7.02 ms
8802.13 img/s9.98 ms10.14 ms10.22 ms10.36 ms
16986.85 img/s16.27 ms16.36 ms16.42 ms16.52 ms
321090.38 img/s29.35 ms29.68 ms29.79 ms30.07 ms
641131.56 img/s56.63 ms57.22 ms57.41 ms57.76 ms
1281167.62 img/s109.77 ms111.06 ms111.27 ms111.85 ms
2561193.74 img/s214.46 ms216.28 ms216.86 ms217.80 ms