NVIDIA Deep Learning Examples
NVIDIA Deep Learning Examples
UNet Medical for TensorFlow2
Resource
NVIDIA Deep Learning Examples
NVIDIA Deep Learning Examples
UNet Medical for TensorFlow2

U-Net allows for seamless segmentation of 2D images, with high accuracy and performance.

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, run one of the TRAIN_BENCHMARK scripts in ./examples/:

bash examples/unet_TRAIN_BENCHMARK{_TF-AMP}.sh <number/of/gpus> <path/to/dataset> <path/to/checkpoints> <batch/size>

For example, to benchmark training using mixed-precision on 8 GPUs use:

bash examples/unet_TRAIN_BENCHMARK_TF-AMP.sh 8 <path/to/dataset> <path/to/checkpoint> <batch/size>

Each of these scripts will by default run 200 warm-up iterations and benchmark the performance during training in the next 800 iterations.

To have more control, you can run the script by directly providing all relevant run parameters. For example:

horovodrun -np <num of gpus> python main.py --exec_mode train --benchmark --augment --data_dir <path/to/dataset> --model_dir <optional, path/to/checkpoint> --batch_size <batch/size> --warmup_steps <warm-up/steps> --max_steps <max/steps>

At the end of the script, a line reporting the best train throughput will be printed.

Inference performance benchmark

To benchmark inference, run one of the scripts in ./examples/:

bash examples/unet_INFER_BENCHMARK{_TF-AMP}.sh <path/to/dataset> <path/to/checkpoint> <batch/size>

For example, to benchmark inference using mixed-precision:

bash examples/unet_INFER_BENCHMARK_TF-AMP.sh <path/to/dataset> <path/to/checkpoint> <batch/size>

Each of these scripts will by default run 200 warm-up iterations and benchmark the performance during inference in the next 400 iterations.

To have more control, you can run the script by directly providing all relevant run parameters. For example:

python main.py --exec_mode predict --benchmark --data_dir <path/to/dataset> --model_dir <optional, path/to/checkpoint> --batch_size <batch/size> --warmup_steps <warm-up/steps> --max_steps <max/steps>

At the end of the script, a line reporting the best inference throughput will be printed.

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 80G)

The following table lists the average DICE score across 5-fold cross-validation. Our results were obtained by running the examples/unet_TRAIN_FULL{_TF-AMP}.sh training script in the tensorflow:21.02-tf2-py3 NGC container on NVIDIA DGX A100 (8x A100 80G) GPUs.

GPUsBatch size / GPUDICE - TF32DICE - mixed precisionTime to train - TF32Time to train - mixed precisionTime to train speedup (TF32 to mixed precision)
180.89000.890221.38.62.48
880.88550.88582.52.51.00
Training accuracy: NVIDIA DGX-1 (8x V100 16G)

The following table lists the average DICE score across 5-fold cross-validation. Our results were obtained by running the examples/unet_TRAIN_FULL{_TF-AMP}.sh training script in the tensorflow:21.02-tf2-py3 NGC container on NVIDIA DGX-1 with (8x V100 16G) GPUs.

GPUsBatch size / GPUDICE - FP32DICE - mixed precisionTime to train - FP32 [min]Time to train - mixed precision [min]Time to train speedup (FP32 to mixed precision)
180.89010.889847162.94
880.88480.885774.51.56

To reproduce this result, start the Docker container interactively and run one of the TRAIN scripts:

bash examples/unet_TRAIN_FULL{_TF-AMP}.sh <number/of/gpus> <path/to/dataset> <path/to/checkpoint> <batch/size>

for example

bash examples/unet_TRAIN_FULL_TF-AMP.sh 8 /data /results 8

This command will launch a script which will run training on 8 GPUs for 6400 iterations five times for 5-fold cross-validation. At the end, it will collect the scores and print the average validation DICE score and cross-entropy loss. The time reported is for one fold, which means that the training for 5 folds will take 5 times longer. The default batch size is 8, however if you have less than 16 Gb memory card and you encounter GPU memory issue you should decrease the batch size. The logs of the runs can be found in /results directory once the script is finished.

Learning curves

The following image show the training loss as a function of iteration for training using DGX A100 (TF32 and TF-AMP) and DGX-1 V100 (FP32 and TF-AMP). LearningCurves

Training performance results

Training performance: NVIDIA DGX A100 (8x A100 80G)

Our results were obtained by running the examples/unet_TRAIN_BENCHMARK{_TF-AMP}.sh training script in the NGC container on NVIDIA DGX A100 (8x A100 80G) GPUs. Performance numbers (in images per second) were averaged over 1000 iterations, excluding the first 200 warm-up steps.

GPUsBatch size / GPUThroughput - TF32 [img/s]Throughput - mixed precision [img/s]Throughput speedup (TF32 - mixed precision)Weak scaling - TF32Weak scaling - mixed precision
1146.8875.041.60--
1863.33141.032.23--
81298.91384.271.296.375.12
88470.501000.892.137.437.10
Training performance: NVIDIA DGX-1 (8x V100 16G)

Our results were obtained by running the examples/unet_TRAIN_BENCHMARK{_TF-AMP}.sh training script in the tensorflow:21.02-tf2-py3 NGC container on NVIDIA DGX-1 with (8x V100 16G) GPUs. Performance numbers (in images per second) were averaged over 1000 iterations, excluding the first 200 warm-up steps.

GPUsBatch size / GPUThroughput - FP32 [img/s]Throughput - mixed precision [img/s]Throughput speedup (FP32 - mixed precision)Weak scaling - FP32Weak scaling - mixed precision
1116.9239.632.34--
1819.4060.653.12--
81120.90225.271.867.145.68
88137.11419.993.067.076.92

To achieve these same results, follow the steps in the Training performance benchmark section.

Throughput is reported in images per second. Latency is reported in milliseconds per image.

TensorFlow 2 runs by default using the eager mode, which makes tensor evaluation trivial at the cost of lower performance. To mitigate this issue multiple layers of performance optimization were implemented. Two of them, AMP and XLA, were already described. There is an additional one called Autograph, which allows to construct a graph from a subset of Python syntax improving the performance simply by adding a @tf.function decorator to the train function. To read more about Autograph see Better performance with tf.function and AutoGraph.

Inference performance results

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

Our results were obtained by running the examples/unet_INFER_BENCHMARK{_TF-AMP}.sh inference benchmarking script in the tensorflow:21.02-tf2-py3 NGC container on NVIDIA DGX A100 (1x A100 80G) GPU.

FP16

Batch sizeResolutionThroughput Avg [img/s]Latency Avg [ms]Latency 90% [ms]Latency 95% [ms]Latency 99% [ms]
1572x572x1275.983.5343.5433.5443.547
2572x572x1376.6810.60310.61910.62310.629
4572x572x1443.0519.57219.61019.61819.632
8572x572x1440.7119.38619.39919.40119.406
16572x572x1462.7937.76037.78337.78837.797

TF32

Batch sizeResolutionThroughput Avg [img/s]Latency Avg [ms]Latency 90% [ms]Latency 95% [ms]Latency 99% [ms]
1572x572x1152.279.3179.3419.3469.355
2572x572x1180.8417.29417.30917.31217.318
4572x572x1203.6031.67631.69831.70231.710
8572x572x1208.7057.74257.75557.75757.762
16572x572x1213.15112.545112.562112.565112.572

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

Inference performance: NVIDIA DGX-1 (1x V100 16G)

Our results were obtained by running the examples/unet_INFER_BENCHMARK{_TF-AMP}.sh inference benchmarking script in the tensorflow:21.02-tf2-py3 NGC container on NVIDIA DGX-1 with (1x V100 16G) GPU.

FP16

Batch sizeResolutionThroughput Avg [img/s]Latency Avg [ms]Latency 90% [ms]Latency 95% [ms]Latency 99% [ms]
1572x572x1142.1510.5376.8516.8536.856
2572x572x1159.2513.23013.24213.24413.248
4572x572x1178.1926.03526.04926.05126.057
8572x572x1188.5443.60243.62743.63143.640
16572x572x1195.2785.74385.80785.81985.843

FP32

Batch sizeResolutionThroughput Avg [img/s]Latency Avg [ms]Latency 90% [ms]Latency 95% [ms]Latency 99% [ms]
1572x572x151.7120.06520.54420.95521.913
2572x572x155.8737.11237.12737.13037.136
4572x572x158.1573.03373.06873.07473.087
8572x572x159.28144.829144.924144.943144.979
16572x572x173.01234.995235.098235.118235.157

To achieve these same results, follow the steps in the Inference performance benchmark section.

Throughput is reported in images per second. Latency is reported in milliseconds per batch.

NVIDIA uses cookies to improve your experience on our web site. We and our third-party partners also use cookies and other tools to collect and record information you provide as well as information about your interactions with our websites for performance improvement, analytics, and to assist in marketing efforts. By clicking "Accept All", you consent to our use of cookies and other tools as described in our Cookie Policy. You can manage your cookie settings by clicking on "Manage Settings." By continuing to use this site or by clicking one of the buttons below, you agree to our Terms of Service (which contains important waivers). Please see our Privacy Policy for more information on our privacy practices.