NVIDIA / CUDALibrarySamples

CUDA Library Samples
Other
1.5k stars 311 forks source link

Using nvjpeg to decode jpegs continuously, causing graphics memory to explode #177

Closed thgpddl closed 6 months ago

thgpddl commented 6 months ago

I perform jpeg decoding by: nvjpegDecode(handle, state, jpegBytes.data(), jpegBytes.size(), NVJPEG_OUTPUT_UNCHANGED, &out_buf, nullptr);, This decode function is written in the custom class decode function

where the initialisation of the handle, state and out_buf declarations is done in the initialisation of the class. I read the image from the disk continuously in a single sheet and call the decode function to decode it, I found that the memory usage of the gpu is increasing, and finally it leads to a Segmentation fault error in nvjpegDecode(), how can I correctly implement the continuous image decoding?

### Tasks
zohebk-nv commented 6 months ago

Hi, Would it be possible for you to share a self contained repro code? I can take a look.

nvjpeg APIs require that the bitstream is already loaded to host memory. If not the library may error out.

The memory required by nvjpeg is depends on the image resolution. As long as the same nvjpegHandle_t and nvjpegJpegState_t are used, and images of the same size are decoded. The memory usage should not increase.

thgpddl commented 6 months ago

Thanks for the reply, I found that I wrote the instantiation of the class inside the loop, so every loop allocated memory in the initialization and eventually the memory exploded. It's fixed now.在 2024年2月27日,03:00,zohebk-nv @.***> 写道: Hi, Would it be possible for you to share a self contained repro code? I can take a look. nvjpeg APIs require that the bitstream is already loaded to host memory. If not the library may error out. The memory required by nvjpeg is depends on the image resolution. As long as the same nvjpegHandle_t and nvjpegJpegState_t are used, and images of the same size are decoded. The memory usage should not increase.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>