cudaBindTextureToArray returns invalid argument with PPM file in SobelFilter example

The SobelFilter example from the CUDA SDK (version 8) reads a grayscale .pgm file, and cudaBindTextureToArray(tex, array) in the sobelFilter() function of works properly in that case. However, when I try to read a 24-bit color .ppm file, where the g_Bpp is 4 instead of 1, cudeBindTextureToArray(tex, array) returns an error: : CUDA Runtime API error 11: invalid argument
extern "C" void sobelFilter(Pixel *odata, int iw, int ih, enum SobelDisplayMode mode, float fScale)
    checkCudaErrors(cudaBindTextureToArray(tex, array));

From SobelFilter.cpp (original .pgm code commented out):

void loadDefaultImage(char *loc_exec)
    //printf("Reading image: lena.pgm\n");
    //const char *image_filename = "lena.pgm";
    printf("Reading image: ref_example.ppm\n");
    const char *image_filename = "ref_example.ppm";
    char *image_path = sdkFindFilePath(image_filename, loc_exec);

    if (image_path == NULL)
        printf("Failed to read image file: <%s>\n", image_filename);


The image appears to be loaded into memory correctly, but I get that error when trying to bind it to a CUDA texture array. How do I get the file to load correctly with cudaBindTextureToArray()?

What have you tried so far, what adjustments have you made to the code? How well do you understand the code of the sample app?

Without having looked at the source code for the app at all, I would think the different pixel size would require you to:

(1) Adjust size of image storage allocations
(2) Adjust CUDA texture declarations
(3) Adjust OpenGL texture type declarations

A 24-bit pixel format may not be a good fit, you may have to convert to a 32-bit pixel format first such as RGBA first, but I am not sure.