Nvjpeg_status_execution_failed

Just upgrading my software to use CUDA 11.4 and I am experiencing a NVJPEG failure when trying to encode and image. Any ideas on how to get more information from the NVJPEG library on why it is failing. Here is the simplified code.

nvjpegCreateSimple(&nv_handle);
// Setup Encoder
nvjpegEncoderStateCreate(nv_handle, &nv_enc_state, stream);
nvjpegEncoderParamsCreate(nv_handle, &nv_enc_params, stream);
nvjpegEncoderParamsSetSamplingFactors(nv_enc_params, NVJPEG_CSS_444, stream);
nvjpegJpegStateCreate(nv_handle, &nv_dec_state);

nvjpegImage_t nv_image;
nv_image.channel[0] = image.data;
nv_image.pitch[0] = image.step;

// this function returns the NVJPEG_STATUS_EXECUTION_FAILED
nvjpegEncodeImage(nv_handle, nv_enc_state, nv_enc_params, &nv_image, NVJPEG_INPUT_BGRI, image.cols, image.rows, stream);

Built the cuda-samples and I am seeing the error there as well.

danr@desktop:~/cuda-samples/bin/sbsa/linux/release$ ./nvJPEG_encoder
GPU Device 0: “Xavier” with compute capability 7.2

Using GPU 0 (Xavier, 6 SMs, 2048 th/SM max, CC 7.2, ECC off)
Processing file: …/…/…/…/Samples/nvJPEG_encoder/images/img4.jpg
Image is 3 channels.
Channel #0 size: 640 x 426
Channel #1 size: 320 x 213
Channel #2 size: 320 x 213
YUV 4:2:0 chroma subsampling
CUDA error at nvJPEG_encoder.cpp:195 code=6(NVJPEG_STATUS_EXECUTION_FAILED) “nvjpegEncodeYUV(nvjpeg_handle, encoder_state, encode_params, &imgdesc, subsampling, widths[0], heights[0], NULL)”

./deviceQuery Starting…

CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: “Xavier”
CUDA Driver Version / Runtime Version 11.4 / 11.4
CUDA Capability Major/Minor version number: 7.2
Total amount of global memory: 6845 MBytes (7177912320 bytes)
(006) Multiprocessors, (064) CUDA Cores/MP: 384 CUDA Cores
GPU Max Clock rate: 1109 MHz (1.11 GHz)
Memory Clock rate: 510 Mhz
Memory Bus Width: 256-bit
L2 Cache Size: 524288 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
Maximum Layered 1D Texture Size, (num) layers 1D=(32768), 2048 layers
Maximum Layered 2D Texture Size, (num) layers 2D=(32768, 32768), 2048 layers
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total shared memory per multiprocessor: 98304 bytes
Total number of registers available per block: 65536
Warp size: 32
Maximum number of threads per multiprocessor: 2048
Maximum number of threads per block: 1024
Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535)
Maximum memory pitch: 2147483647 bytes
Texture alignment: 512 bytes
Concurrent copy and kernel execution: Yes with 1 copy engine(s)
Run time limit on kernels: No
Integrated GPU sharing Host Memory: Yes
Support host page-locked memory mapping: Yes
Alignment requirement for Surfaces: Yes
Device has ECC support: Disabled
Device supports Unified Addressing (UVA): Yes
Device supports Managed Memory: Yes
Device supports Compute Preemption: Yes
Supports Cooperative Kernel Launch: Yes
Supports MultiDevice Co-op Kernel Launch: Yes
Device PCI Domain ID / Bus ID / location ID: 0 / 0 / 0
Compute Mode:
< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 11.4, CUDA Runtime Version = 11.4, NumDevs = 1
Result = PASS

thanks

Dan

Hi,
The software stack is for discrete GPU and mat not work properly on Jetson devices. Please check jetson_multimedia_api samples to use NVJPG engine:

/usr/src/jetson_multimedia_api/samples/05_jpeg_encode/
/usr/src/jetson_multimedia_api/samples/06_jpeg_decode/

And the latest releases for Xavier is 4.6.4 and 5.1.2. If you use previous version, we would suggest upgrade to latest 4.6.4 or 5.1.2.

Thanks,

We used to use NPP, but that looks like it is deprecated, which is why were trying to use NVJPEG.

“Note that NPP has deprecated the nppicom JPEG compression library as of NPP 11.0, use the NVJPEG library instead.”

How would I use a cuda::GpuMat& image with the NVBufSurf?

Hi,
You can create NvBufSurface and map it to cuda::GpuMat. Please refer to
Error generated while running the code after connecting the camera - #15 by DaveYYY
OpenCV CUDA processing from gstreamer pipeline [JP4, JP5]

It is not supported to map cuda::GpuMat to NvBufSurface.