fablnx/engineering
Gokul Adethya · Fablnx · A bug in NVIDIA NPP

How we tracked a bug in NVIDIA’s NPP down to nine pixels

Ask NVIDIA's NPP how many regions there are in a 3 × 3 picture, and every version we tested from 12.3.3 to 13.2.0 gets it wrong, every run, on whichever of our three GPUs it ran on. Ask it about the sample images NVIDIA ships, and the wrong answer changes from run to run. NVIDIA's sample program gets it wrong, and so do the output files NVIDIA published. It was reported on NVIDIA's forum in 2021. It is still there in every version we tested, 11.8 to 13.2. We reported it to NVIDIA in October 2026, and their NPP team has fixed it for CUDA 13.6.

We build Fablnx, which reads structural drawings, and the first step of reading one is connected-component labelling: grouping touching pixels of the same colour into regions. NPP, the image-processing library NVIDIA ships with CUDA, has a function for exactly that. On our drawings it broke. So we wrote our own, and then set out to prove the fault was not ours.

An update to our last post. In “Accountable AI starts at the pixel” (and on LinkedIn), we wrote about the GPU labeller we built and mentioned in passing that we had reported a bug in NPP. This is the full story of that bug, and of NVIDIA's fix.

Fixed for CUDA 13.6. We reported this to NVIDIA on 20 October 2026 (bug 6963973, forum thread). NVIDIA reproduced it the next day, and on 28 October their NPP team verified a fix on the nine-pixel reproducer. The fix is scheduled for CUDA 13.6; until then, releases 11.8 to 13.2 still behave as described below. Timeline and links.
01 · Nine pixels

Nine pixels, four regions

Here are nine pixels. Five are dark, and every dark pixel touches another one. The bottom one touches only at its corners, but corners count here, so the five form one region. Add the two blue pixels, one region each, and the grey pair in the middle: four regions in all.

NPP 13.2 says five. It cuts the top-right dark pixel off into a region of its own, every run, on an RTX 3070 and an RTX 4060 Ti (on the A100, whose driver only runs NPP 12, versions 12.3 and 12.4 do the same):

Fig. 1Nine pixels, labelled with 8 neighbours
Each number is the label the program wrote for that pixel. The right answer may number its regions any way it likes; what matters is which pixels share a number. NPP writes the index of each pixel's leader: index 2, top right, still leads itself although its neighbour below belongs to leader 0.

That is one call to nppiLabelMarkersUF_8u32u_C1R_Ctx, made the way NVIDIA's sample makes it. Our standalone test makes that one call, checks the answer, and exits with status 2 when it is wrong. Every NPP we tested from 12.3.3 to 13.2.0 is wrong on every run; 11.8.0 gets these nine pixels right and fails the same way once the shape is a pixel taller.

Nine pixels is the smallest case. The same cut happens wherever two arms of one colour meet at the bottom:

Fig. 2The smallest inputs NPP gets wrong, next to two ground truths
Every number is the label the program wrote for that pixel. cc3d (CPU) and our kernel (Metal) write the same files, byte for byte. NPP writes each pixel's leader index; red pixels carry a label that disagrees with the rest of their region. NPP 13.2 cuts the V and the U in every run at this position; 11.8 gets these two right (it needs taller arms, Fig. 7) but gives the two pixels of the row wrap one label.
02 · NVIDIA's own images

Not our pictures, not our program

Before calling a vendor library wrong, we took our own code out of the picture. The CUDA samples include a program for exactly this function, with five sample images. We ran NPP on those images the way that program does, then built the program itself, unchanged, and ran that too.

Move over any picture (or tap it) and the frame follows in all four, or step through NPP's mistakes one by one. Pictures are coloured by true region; NPP's labels take the colour of the true region they mostly cover, so where NPP is right its picture matches cc3d's, and every piece it cut off has a strong colour of its own. cc3d is a CPU library; "ours" is the GPU labeller from our last post. The two share no code and write the same files, byte for byte.

NVIDIA sample imagecc3doursNVIDIA's committed output (tag v12.8, NPP 12.0.0)NVIDIA's sample program, NPP 12.4.1, RTX 3070, run 1NPP 13.2.0, RTX 3070, 30 runs
teapot155,343155,343155,333155,343155,343 every run
PCB_METAL3,7323,7323,7323,7333,732–3,735; wrong in 28
CT_skull407407415434431–439; wrong in 30
PCB21,2021,2021,2251,2721,270–1,277; wrong in 30
PCB1,4361,4361,4411,4691,473–1,481; wrong in 30

8 neighbours throughout; counts are for the single-image call. cc3d and our kernel give identical label files on all five images. NPP's count changes from run to run. With 12.4.1 and later it is never below the truth, because those versions only cut regions; NPP 12.0.0 (NVIDIA's files) and 11.8 also join regions across row ends, which is how the teapot comes out with too few labels. NVIDIA's committed files are judged by our checker; the report links each one.

The sample program, built unmodified against NPP 12.4.1, writes wrong labels on three or four of its five images in every run: over twenty runs, the fourth came out right only once. The samples repository also includes the files that program wrote when NVIDIA ran it, around the CUDA 12.0 release, twice: at tag v12.8 (its log says NPP 12.0.0) four of the five images are wrong, and at the earlier tag v12.5 all five are. Here is every mistake in the PCB file from tag v12.8:

Left: the whole image, grey where NPP is right; each red number is a cut, each purple one a pair of regions joined across a row end. Right: the 48 × 48 pixels around the selected mistake, in the input, in the right answer and in NPP's labels.

03 · Different every run

Same picture, different answer

Run NVIDIA's sample ten times on the same machine with the same input, and it prints four different region counts for the CT skull: 433, 434, 435 and 437. The answer is 407.

Labelling has one right answer. Which pixels belong together is fixed by the picture; only the numbers on the groups are free, and NPP's documentation says its numbers come in no particular order. So we never compare numbers. A labelling is wrong in exactly two ways: two touching pixels of one colour carry different labels (a region split), or one label covers two regions (two regions merged). NPP's runs differ in which regions they split.

Small shapes are wrong the same way every time: inside a 16 × 16 block of pixels, a variant of the nine-pixel picture failed in 200 of 200 runs at each of 15 positions. Moved so that it straddles the edge of such a block, NPP 13 labels it correctly, which suggests NPP labels the image in 16 × 16 tiles and then joins the tiles. Once regions span many tiles, the wrong answer changes from run to run, as if the order in which threads happen to finish decides which joins are lost.

A GPU labeller does not have to behave like that. Ours numbers each region by its first pixel in reading order, so even the numbers are fixed: 50 runs of each image on the same GPU give byte-identical files, and right ones.

04 · Ruling ourselves out

Everything we could have done wrong

A wrong answer from a vendor library is usually the caller's fault. So we tried every misuse we could think of, one at a time, on every version: bigger and pre-filled buffers, other streams, other input types, the batch API. None makes the images right.

The full list
  • Scratch buffer zeroed, left uninitialised, filled with 0xFF, or four and sixteen times the size NPP asks for.
  • Output buffer zeroed or pre-filled; rows pitched with cudaMallocPitch; row steps in bytes, as documented.
  • The default stream, our own stream, NPP's own nppGetStreamContext, and a context zeroed except for the stream.
  • 8-, 16- and 32-bit input; values 0/255 as well as 0/1/2; nppiNormInf for 8 neighbours.
  • The batch API, called with two images per call as its documentation asks: wrong on 40 of 40 random 64 × 64 images, and so is the single-image call on the same images, on NPP 11.8, 12.4 and 13.2.
  • Labels read before and after nppiCompressMarkerLabelsUF.

Our test program is plain CUDA C++ with no framework. It loads NPP at run time, so one binary tests every version, and it checks every call against a simple CPU labeller.

And NVIDIA's newer library

NVIDIA also publishes NPP+, a separate library with its own C++ interface, its own copy of the sample, and its own committed output files. All ten of those files are wrong, and so are all ten of the first run when we build that sample and run it ourselves. NPP+ 0.10.0 reports its version as 12.4.0 and fails exactly where NPP 12.4.1 fails, on every small shape we tried.

05 · Inside the join

Point the leader, not the neighbour

Almost every fast labeller is built on union-find. Each pixel stores one number, the pixel it points at; follow the arrows and you reach the region's leader, a pixel that points at itself. To join two regions, you point one region's leader at the other's. Step through the nine pixels of Fig. 1, done right:

NPP returns, for each pixel, the index of its leader, so its output shows the arrows. They look as if NPP pointed the neighbour at the other region's leader, instead of the neighbour's own leader. Locally that looks the same. But the old leader is left behind, pointing at itself, leading a region of its own. Replayed that way, the nine pixels come out exactly as NPP labelled them:

We measured every pair of arm heights from 1 to 5, in two shapes and three versions. A rule built on that reading has six numbers, one per shape and version: how far up the arm NPP re-points. We fitted them by hand to these measurements, so the rule describes them rather than predicts them; with them it agrees with measured cases:

Fig. 7Inside the union: a correct one, and NPP's
left armright arm
a correct union
what NPP does
Measured on the RTX 3070: every pair of arm heights, three versions · ✕ = NPP split the shape · click one to load it
Arrows point from each pixel to its parent; ringed pixels are leaders; red pixels are cut off from the region. The left drawing is what any correct union-find writes. The right one follows the rule we read off NPP's raw output; the line under them gives what NPP actually returned for that shape.

NPP is closed source, so this is its behaviour seen from outside, not its code. In the code we can see, our own, the safe join is a loop: find both leaders, point one at the other with an atomic minimum, and look again if someone moved first.

06 · Unnoticed

How it went unnoticed

We are not the first to see this. Two NVIDIA forum threads from 2021 (184854, 188097) report regions split by this function, and the CUDA 11.5 release notes list a fix for "column processing incorrect results" in it. The first thread's own example is labelled correctly by NPP 11.8.0, 12.4.1 and 13.2.0, so what we see is either a different trigger or a fix that was not complete. It is in every version we tested, 11.8.0 to 13.2.0.

It is easy to miss. The sample program checks NPP's status codes, not the labels it writes. On a photograph most regions are small: NPP 13.2 labelled the teapot correctly in all 30 runs, and random images with 256 values never failed. Where it is wrong, the count is off by a few percent (431 to 439 labels for the skull's 407 regions) or not at all (3,732 to 3,735 for the 3,732 regions of PCB_METAL, right in 2 of 30 runs), and a region split in two looks like two regions. Because the answer changes from run to run, a failure is hard to show twice.

Drawings are different. A wall line, or the paper itself, crosses thousands of tiles, which is exactly where NPP goes wrong, and where we first saw it.

07 · If you use NPP

What to do today

Check the labels, not just the status code. It takes ten lines: label each colour on the CPU, then count the regions that got more than one label and the labels that cover more than one region. Both should be zero.



Everything is public: the nine-pixel program, every input and output file, every log, the checksums, and the scripts that rerun it all on a rented GPU. The full report · the thread on NVIDIA's forum.
08 · Reported and fixed

Reported, reproduced, fixed

Bugs like this turn up in every large library; what counts is how quickly they get fixed. NVIDIA's NPP team reproduced this one within a day and had a verified fix a week later. We are grateful to them.

A note from Gokul. This was my first bug report to NVIDIA, and I am excited to have contributed something back to a library so many people build on. If NPP were open source, I would have loved to try writing the fix myself: after this long inside its union-find, it is the kind of bug that is fun to finish.