NVIDIA Deep Learning Examples
NVIDIA Deep Learning Examples
NCF for PyTorch
Resource
NVIDIA Deep Learning Examples
NVIDIA Deep Learning Examples
NCF for PyTorch

The NCF model focuses on providing recommendations. This is a modified implementation with improved overfitting and better accuracy.

  • 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

    Training performance benchmark

    NCF training on NVIDIA DGX systems is very fast; therefore, in order to measure train and validation throughput, you can simply run the full training job with:

    ./prepare_dataset.sh
    python -m torch.distributed.launch --nproc_per_node=8 --use_env ncf.py --data /data/cache/ml-20m --epochs 5
    

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

    Inference performance benchmark

    Validation throughput can be measured by running the full training job with:

    ./prepare_dataset.sh
    python -m torch.distributed.launch --nproc_per_node=8 --use_env ncf.py --data /data/cache/ml-20m --epochs 5
    

    The best validation throughput is reported to the standard output.

    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 following the steps in the Quick Start Guide in the PyTorch 21.04-py3 NGC container on NVIDIA DGX A100 (8x A100 40GB) GPUs.

    The following table lists the best hit rate at 10 for DGX A100 with 8 A100 40GB GPUs. It also shows the time to reach this HR@10. Results are averages across 20 random seeds.

    GPUsBatch size / GPUAccuracy - TF32Accuracy - mixed precisionTime to train - TF32Time to train - mixed precisionTime to train speedup (TF32 to mixed precision)
    110485760.9589250.958892140.77194.23861.49
    81310720.9589380.95908930.092823.73621.27
    Training accuracy: NVIDIA DGX-1 (8x V100 16GB)

    Our results were obtained by following the steps in the Quick Start Guide in the PyTorch 21.04-py3 NGC container on NVIDIA DGX-1 with 8x V100 16GB GPUs.

    The following table lists the best hit rate at 10 for DGX-1 with 8 V100 16GB GPUs. It also shows the time to reach this HR@10. Results are averages across 20 random seeds. The training time was measured excluding data downloading, preprocessing, validation data generation and library initialization times.

    GPUsBatch size / GPUAccuracy - FP32Accuracy - mixed precisionTime to train - FP32Time to train - mixed precisionTime to train speedup (FP32 to mixed precision)
    110485760.9588570.958815302.443145.4232.08
    81310720.9587680.95905253.704434.25031.57

    To reproduce this result, start the NCF Docker container interactively and run:

    ./prepare_dataset.sh
    python -m torch.distributed.launch --nproc_per_node=8 --use_env ncf.py --data /data/cache/ml-20m
    
    Training accuracy: NVIDIA DGX-1 (8x V100 32GB)

    Our results were obtained by following the steps in the Quick Start Guide in the PyTorch 21.04-py3 NGC container on NVIDIA DGX-1 with 8x V100 32GB GPUs.

    The following table lists the best hit rate at 10 for DGX-1 with 8 V100 32GB GPUs. It also shows the time to reach this HR@10. Results are averages across 20 random seeds. The training time was measured excluding data downloading, preprocessing, validation data generation and library initialization times.

    GPUsBatch size / GPUAccuracy - FP32Accuracy - mixed precisionTime to train - FP32Time to train - mixed precisionTime to train speedup (FP32 to mixed precision)
    110485760.9589920.959002310.467153.6162.02
    81310720.958710.95892555.71636.33841.53

    To reproduce this result, start the NCF Docker container interactively and run:

    ./prepare_dataset.sh
    python -m torch.distributed.launch --nproc_per_node=8 --use_env ncf.py --data /data/cache/ml-20m
    
    Training accuracy: NVIDIA DGX-2 (16x V100 32GB)

    Our results were obtained by following the steps in the Quick Start Guide in the PyTorch 21.04-py3 NGC container on NVIDIA DGX-2 with 16x V100 32GB GPUs.

    The following table lists the best hit rate at 10 for DGX-2 with 16 V100 32GB GPUs. It also shows the time to reach this HR@10. Results are averages across 20 random seeds. The training time was measured excluding data downloading, preprocessing, validation data generation and library initialization times.

    GPUsBatch size / GPUAccuracy - FP32Accuracy - mixed precisionTime to train - FP32Time to train - mixed precisionTime to train speedup (FP32 to mixed precision)
    110485760.9587560.958833289.004143.612.01
    81310720.9588640.95880652.178833.74561.55
    16655360.9589050.95889337.707527.1741.39

    To reproduce this result, start the NCF Docker container interactively and run:

    ./prepare_dataset.sh
    python -m torch.distributed.launch --nproc_per_node=16 --use_env ncf.py --data /data/cache/ml-20m
    
    Influence of AMP on accuracy

    The box plots below show the best accuracy achieved in each run. Twenty experiments were performed for each configuration.

    hr_boxplot

    Training validation curves

    The plots below show the validation accuracy over the course of training. One sample curve is shown for each configuration.

    validation_accuracy

    Training performance results

    Results are averages over 20 runs for each configuration.

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

    Our results were obtained by following the steps in the Quick Start Guide in the PyTorch 21.04-py3 NGC container on NVIDIA DGX A100 (8x A100 40GB) GPUs. Performance numbers (in items per second) were averaged over an entire training epoch.

    GPUsBatch size / GPUThroughput - TF32 (samples/s)Throughput - mixed precision (samples/s)Throughput speedup (TF32 to mixed precision)Strong scaling - TF32Strong scaling - mixed precision
    1104857622.59M34.08M0.6611
    8131072110.16M142.90M0.774.884.19
    Training performance: NVIDIA DGX-1 (8x V100 16GB)

    Our results were obtained by following the steps in the Quick Start Guide in the PyTorch 21.04-py3 NGC container on NVIDIA DGX-1 with 8x V100 16GB GPUs.

    The following table shows the best training throughput:

    GPUsBatch size / GPUThroughput - FP32 (samples/s)Throughput - mixed precision (samples/s)Throughput speedup (FP32 to mixed precision)Strong scaling - FP32Strong scaling - mixed precision
    1104857610.42M21.84M0.4811
    813107260.03M95.95M0.635.764.39
    Training performance: NVIDIA DGX-1 (8x V100 32GB)

    Our results were obtained by following the steps in the Quick Start Guide in the PyTorch 21.04-py3 NGC container on NVIDIA DGX-1 with 8x V100 32GB GPUs.

    The following table shows the best training throughput:

    GPUsBatch size / GPUThroughput - FP32 (samples/s)Throughput - mixed precision (samples/s)Throughput speedup (FP32 to mixed precision)Strong scaling - FP32Strong scaling - mixed precision
    1104857610.14M20.65M0.4911
    813107258.50M91.77M0.645.774.44
    Training performance: NVIDIA DGX-2 (16x V100 32GB)

    Our results were obtained by following the steps in the Quick Start Guide in the PyTorch 21.04-py3 NGC container on NVIDIA DGX-2 with 16x V100 32GB GPUs.

    The following table shows the best training throughput:

    GPUsBatch size / GPUThroughput - FP32 (samples/s)Throughput - mixed precision (samples/s)Throughput speedup (FP32 to mixed precision)Strong scaling - FP32Strong scaling - mixed precision
    1104857610.90M22.16M0.4911
    813107262.16M98.56M0.635.74.45
    166553692.20M134.91M0.688.466.09

    Inference performance results

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

    Our results were obtained by running the inference.py script in the PyTorch 21.04 NGC container on NVIDIA DGX A100 with 1x A100 GPU.

    TF32

    Batch sizeThroughput AvgLatency AvgLatency 90%Latency 95%Latency 99%
    10242.96198e+060.0003460.000370.0003740.000383
    40961.16823e+070.0003510.0003750.0003820.000389
    163844.01876e+070.0004080.0004420.0004430.000445
    655365.06161e+070.0012950.0013190.0013210.001324
    2621445.62193e+070.0046630.0046550.004660.005091
    10485765.74678e+070.0182460.0182580.0182610.018276

    FP16

    Batch sizeThroughput AvgLatency AvgLatency 90%Latency 95%Latency 99%
    10242.9068e+060.0003520.0003790.0003830.000401
    40961.1149e+070.0003670.0003940.0003960.000402
    163844.46873e+070.0003670.0003910.0003970.000406
    655367.15357e+070.0009160.0010640.0010680.001071
    2621448.02216e+070.0032680.003270.0032720.00338
    10485768.27085e+070.0126780.0126850.0126880.012809
    Inference performance: NVIDIA DGX-1 (1x V100 16GB)

    Our results were obtained by running the inference.py script in the PyTorch 21.04 NGC container on NVIDIA DGX-1 with 1x V100 16GB GPU.

    FP32

    Batch sizeThroughput AvgLatency AvgLatency 90%Latency 95%Latency 99%
    10241.91315e+060.0005350.0005570.0005650.000589
    40967.4782e+060.0005480.0005660.0005770.000718
    163842.15241e+070.0007610.0007830.0007910.000842
    655362.77005e+070.0023660.002420.0024310.002435
    2621442.95251e+070.0088790.0088880.0088950.008932
    10485762.92491e+070.035850.036030.0360780.036144

    FP16

    Batch sizeThroughput AvgLatency AvgLatency 90%Latency 95%Latency 99%
    10242.00172e+060.0005120.0005380.0005460.000577
    40968.08797e+060.0005060.0005190.0005350.000569
    163843.22482e+070.0005080.0005160.0005190.000557
    655365.20587e+070.0012590.0012650.0012670.001278
    2621445.66404e+070.0046280.0046360.0046380.004642
    10485765.66507e+070.0185090.0185470.0185560.018583