Skip to content
VLASIFY™
TutorialHPC, GPU & Linux

How to benchmark GPU performance for scientific workloads

Updated · Scientifically reviewed by Dinkar Mishra, PhD on

Short answer

Benchmark in three layers: (1) health and configuration, using nvidia-smi and NVIDIA DCGM diagnostics (clocks, power limits, PCIe link, errors); (2) micro-benchmarks for memory bandwidth and matrix-multiply FLOP/s, compared with the vendor's specifications; (3) your real application on a representative case, measuring time per step or time to solution. Always warm up, synchronise before timing, repeat runs and report the software versions.

Who this is for

Researchers and administrators validating new GPU servers, comparing cloud instances, or checking whether a GPU performs as expected.

Software

NVIDIA driver + DCGM currentCuPy ≥ 13 (for the Python micro-benchmarks)

Prerequisites

  • Exclusive access to the GPU (no other jobs running). On a cluster, request a whole GPU with Slurm.
  • The vendor’s specification sheet for your GPU model: peak memory bandwidth and peak FLOP/s per precision.
  • CuPy for the Python micro-benchmarks (python -m pip install cupy-cuda12x).

Step 1: health and configuration

nvidia-smi -q -d CLOCK,POWER,PERFORMANCE,ECC | less    # clocks, power limit, throttle reasons, ECC
nvidia-smi -q | grep -A3 -i "link width"                # PCIe width: current vs max
dcgmi diag -r 2                                          # DCGM medium diagnostic (if DCGM is installed)

Look for active throttle reasons (thermal, power cap), uncorrected ECC errors, and a reduced PCIe link. Fix these before measuring performance.

Step 2: memory bandwidth

A device-to-device copy streams memory at close to the attainable bandwidth:

import cupy as cp

n_bytes = 2 * 1024**3                        # 2 GiB per buffer
src = cp.empty(n_bytes // 8, dtype=cp.float64)
dst = cp.empty_like(src)
start, stop = cp.cuda.Event(), cp.cuda.Event()

dst[...] = src                               # warm-up
reps = 20
start.record()
for _ in range(reps):
    dst[...] = src
stop.record()
stop.synchronize()
seconds = cp.cuda.get_elapsed_time(start, stop) / 1e3 / reps
print(f"copy bandwidth: {2 * n_bytes / seconds / 1e9:.0f} GB/s (read + write)")

Compare with the specification. Streaming copies typically reach a large fraction of peak; a result far below suggests a configuration problem.

Step 3: compute throughput

Large matrix multiplications approach peak arithmetic throughput:

import cupy as cp

n = 8192
for dtype in (cp.float32, cp.float64):
    a = cp.random.default_rng(0).random((n, n), dtype=dtype)
    b = cp.random.default_rng(1).random((n, n), dtype=dtype)
    a @ b                                    # warm-up
    start, stop = cp.cuda.Event(), cp.cuda.Event()
    start.record()
    for _ in range(5):
        a @ b
    stop.record()
    stop.synchronize()
    t = cp.cuda.get_elapsed_time(start, stop) / 1e3 / 5
    print(f"{cp.dtype(dtype).name}: {2 * n**3 / t / 1e12:.1f} TFLOP/s")

Matrix multiplication counts 2n32n^3 floating-point operations. Libraries may use Tensor Cores for FP32 inputs (TF32 mode), depending on settings, which raises the FP32 result. Note which mode was active.

Interpreting the numbers

Place your application on a roofline. Divide its floating-point operations per step by the bytes it moves (estimated, or measured with a profiler such as Nsight Compute). That gives its arithmetic intensity. If the intensity is low, the copy bandwidth from step 2 is the ceiling that matters; if it is high, the FLOP/s from step 3 is. This tells you whether a faster GPU memory system or more compute would help your workload.

Step 4: your application

Synthetic numbers bound performance; the decision rests on your code. Pick a representative input, run several steps after warm-up, and record time per step, total time, GPU utilisation (nvidia-smi dmon) and peak memory. Repeat three times and report the spread.

Verify

A trustworthy benchmark report includes the GPU model, driver, CUDA and library versions, clocks and power limits, the problem size, the number of repetitions with their spread, and the exact command. Repeat on a second GPU of the same model: large differences between identical GPUs indicate a hardware or cooling problem.

Troubleshooting

  • Results vary a lot between runs: thermal or power throttling, shared GPUs, or CPU frequency scaling affecting launch overheads. Check throttle reasons in step 1.
  • FP64 throughput far below FP32: expected on most consumer GPUs. Check the specification before concluding something is wrong.
  • Host-to-device transfers are slow: check the PCIe link width, and use pinned (page-locked) host memory for transfer benchmarks.

Assumptions and limitations

  • Commands target NVIDIA GPUs. AMD GPUs use rocm-smi, rocm-bandwidth-test and ROCm libraries.
  • The micro-benchmarks are simple and indicative. Vendor tools and the CUDA samples provide more rigorous measurements.
  • No performance numbers are quoted here; they depend on the GPU model and configuration. Compare against your own GPU’s specifications.

Frequently asked questions

Why is my measured bandwidth below the specification?+

Vendor peak bandwidth is a theoretical maximum. Well-written streaming kernels typically reach a large fraction of it but not all. A much lower result can indicate small transfer sizes, ECC or clock settings, thermal or power throttling, or a measurement including host transfers.

Should I benchmark in FP32 or FP64?+

Benchmark in the precision your application uses. GPU FP64 throughput varies enormously between data-centre and consumer models, and Tensor Core (mixed-precision) peaks only apply to matrix operations that use them.

What is the PCIe link check for?+

A GPU running at a reduced PCIe width or generation (for example x4 instead of x16) transfers data to the host much more slowly. nvidia-smi -q shows the current and maximum link width and generation.

Are synthetic benchmarks enough to choose hardware?+

No. They detect faulty or misconfigured hardware and bound what is possible. Purchase decisions should be based on your own application benchmarks at representative problem sizes.

References

  1. NVIDIA DCGM user guide: diagnostics · NVIDIA
  2. nvidia-smi documentation · NVIDIA
  3. CUDA samples (bandwidthTest, deviceQuery) · NVIDIA (GitHub)
  4. Williams, Waterman & Patterson, Roofline model, Commun. ACM 52(4), 65 (2009) · Peer-reviewed article

Want this set up and verified for you?

We install, configure and validate scientific software on your workstation, cluster or cloud, and train your team to run it.

Services listed on this page are available today. Products marked “early access” or “in development” on our platform page are not yet generally available.

Spotted an error or an outdated command? Tell us. We correct verified issues promptly.

Related guides

How Vlasify can help

Get a Quote