CESNET/GPUJPEG

Help with GPUJPEG and Torch Tensor

Closed this issue · 5 comments

Hi @MartinPulec,

I am facing an issue using GPUJPEG and torch, I want to copy the output decoded data of the jpg to a cuda tensor. I implement a copy function in cuda in order to copy the decoder data directly to the tensor.
My cuda code is splitting the three channel and normalize. I have a tool to convert the tensor into an images to check if its working. If I put some color its ok, but if I used the &coder->d_data_raw[0] as source everything seems to be working fine except for one part of the images

I am looking if I make a mistake in my code but I would like to know if I use the correct approach. I am using coder->d_data_raw in order to access to the gpu memory, also I assuming inside the pointer I will have the data RGBRGBRGB with the same width and height. Am I correct ?

Original image save with GPUJPEG
gpujpeg2tensor

After loading into a tensor and saved again

gpujpeg2tensor2

I am receiving this warning message during this process :

[GPUJPEG] [Warning] JPEG scan contains no data after last restart marker!

Do you think that can be related, does it mean my jpg is not complete ?

Thanks

Hi @wolfviking0,

[GPUJPEG] [Warning] JPEG scan contains no data after last restart marker!

Do you think that can be related, does it mean my jpg is not complete ?

Provided that the JPEG is generated by GPUJPEG it looks so (if it were encoded by FFMPEG, it doesn't need to be, see here).

Nevertheless, your approach seems quite OK, except a more favorable way of doing this is to use a function gpujpeg_decoder_output_set_custom_cuda instead of using GPUJPEG internal structures.

Also, I'd suggest to try cudaStreamSynchronize or cudaDeviceSynchronize after the decode.

EDIT: Taking back all above, it is just a regression in the latest code, I'll fix it ASAP.

I've fixed two small issues which should have caused this.

Martin

@MartinPulec I just rebuild everything and I do not have the trouble anymore.

Thanks for fixing the issue, I still use coder->d_data_raw but I will update the code to use gpujpeg_decoder_output_set_custom_cuda.