DALI icon indicating copy to clipboard operation
DALI copied to clipboard

NVJPEG error "2" : nvJPEG error (2): Wrong parameter was passed. For example, a null pointer as input data, or an image index not in the allowed range.

Open CoinCheung opened this issue 4 months ago • 2 comments

Version

1.51.2

Describe the bug.

Here is the image:

Image

Here is code to reproduce:


import numpy as np
from nvidia.dali import pipeline_def
import nvidia.dali.fn as fn
import nvidia.dali.types as types


class ExternalInputCallable:
    def __init__(self):
        pass

    def __call__(self, sample_info):
        sample_idx = sample_info.idx_in_epoch
        if sample_idx >= 1000:
            # Indicate end of the epoch
            raise StopIteration()

        with open('./n03287733_3194.JPEG', 'rb') as fr:
            encoded_img = np.frombuffer(fr.read(), dtype=np.uint8)
        return encoded_img, np.array(sample_idx)


@pipeline_def(
    batch_size=1, num_threads=1, device_id=0, py_num_workers=1
)
def loader_pipeline():
    jpegs, inds = fn.external_source(
        source=ExternalInputCallable(),
        num_outputs=2,
        batch=False,
        parallel=True,
        dtype=[types.UINT8, types.INT64],
    )
    decode = fn.decoders.image(jpegs, device="mixed")
    return decode, inds



pipe = loader_pipeline()
pipe.start_py_workers()
pipe.build()


for i in range(10):
    with warnings.catch_warnings():
        warnings.simplefilter('error')
        try:
            one_out = pipe.run()
            img = np.array(one_out[0][0].as_cpu())
            ind = np.array(one_out[1][0])
        except Exception as e:
            print(i, ': ', str(e))

Relevant log output

/opt/dali/dali/operators/decoder/nvjpeg/nvjpeg_decoder_decoupled_api.h:1070] NVJPEG error "2" : nvJPEG error (2): Wrong parameter was passed. For example, a null pointer as input data, or an image index not in the allowed range.

Other/Misc.

No response

Check for duplicates

  • [x] I have searched the open bugs/issues and have found no duplicates for this bug report

CoinCheung avatar Sep 13 '25 23:09 CoinCheung

Hi @CoinCheung,

Thank you for reporting this. DALI uses various libraries to decode images. Sometimes, a particular library may not support a certain format, so we switch to a different implementation to decode the image. This is what occurred in your case. Our primary library, nvjpeg, couldn't handle your image, leading to the error log you encountered. The image is correctly decoded with a different library, but I agree that the error log might be confusing. We will consider removing it.

jantonguirao avatar Sep 15 '25 09:09 jantonguirao

@jantonguirao So there is no problem when we see this error message, and everything is working as expected, right?

CoinCheung avatar Sep 15 '25 09:09 CoinCheung