Issue with cudaMemcpy2DToArray with Pytorch

I have a tensor of size {height, width, 3 channels} with uin8_t format. I used the interoperability with OpenGL to link a cuda array to a GL_TEXTURE_2D. I init the texture with :

GL_RGB8, Width, Height, GL_RGB, GL_UNSIGNED_BYTE.

I show by OpenCv the tensor to show that is correct and does not have an issue (see the picture called “show_byte” below).
So I use to put it in the OpenGL Texture this method :

cudaMemcpy2DToArray( cudaArray pointer, 0, 0, tensor.data_ptr<uint8_t>(), (spitch) Width x 3, Width x 3, Height, cudaMemcpyDeviceToDevice);

spitch = Width*3 because it’s a RGB image with data of 1 byte.

But, unfortunately I have the all image data in the Texture but with an issue with the width (see the picture called “Texture output 4”) :

If someone could give me ideas to solve my issue. Thanks.

Hi @PaulErMartin
This forum branch is dedicated to CUDA-GDB tool support. Your question might be better suited for
CUDA Programming and Performance - NVIDIA Developer Forums or GPU-Accelerated Libraries - NVIDIA Developer Forums

I have moved your topic to CUDA Programming and Performance - NVIDIA Developer Forums