OpenCV Cuda Demosaicing function Problem / error: (-217) unknown error in function bindTexture

Good day, everyone.

I am currently trying to implement Image Demosaicing (debayering)
by OpenCV3.1 with CUDA8.0 on Nvidia Jetson TX1 board,
and suffering from unsolved errors.

Following code is the problematic part.

cv::cuda::GpuMat debayeredImage_cuda;

PvImage* lImage_raw = lBuffer->GetImage();
lImage_raw->Alloc(lWidth, lHeight, PvPixelMono8);
unsigned char* img = lImage_raw->GetDataPointer();

cv::cuda::GpuMat rawImage_cuda(lHeight, lWidth, CV_8UC1, img, cv::Mat::AUTO_STEP);

//---------Following Line Occurs ERROR-----------//
cv::cuda::demosaicing(rawImage_cuda, debayeredImage_cuda, cv::cuda::COLOR_BayerGB2RGB_MHT, 3);

Error Message is
OpenCV Error: Gpu API call (unknown error) in bindTexture, file /media/ubuntu/payload/opencv/modules/core/include/opencv2/core/cuda/common.hpp, line 102
/media/ubuntu/payload/opencv/modules/core/include/opencv2/core/cuda/common.hpp:102: error: (-217) unknown error in function bindTexture

And this is the error-triggering file common.hpp:102

cudaSafeCall( cudaBindTexture2D(0, tex, img.ptr(), &desc, img.cols, img.rows, img.step) );

I followed OpenCV installation manual for Jetson TX1 ( )
in order to build OpenCV 3.1 combining pre-built CUDA8.0.

And here is my cmake command.

cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_opencv_java=ON \
    -DBUILD_opencv_python2=OFF \
    -DBUILD_opencv_python3=OFF \
    -DWITH_1394=OFF \
    -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \
    -DCUDA_ARCH_BIN=5.3 \
    -DCUDA_ARCH_PTX="" \
    -DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \

I downgrade from OpenCV 3.3 to OpenCV 3.1 because the same error occured in 3.3, but still it’s not fixed in 3.1.

I carefully suggest following possible scenarios.

  1. DCUDA_ARCH_BIN. I searched a lot from google, and many of them talked about DCUDA_ARCH_BIN, which is 5.3 in my case. However, the version 5.3 is suitable as Nvidia informed in the web-site, so I think this is not a problem.
  2. Misuse of cv::cuda::demosaicing( , , , ) function in my code. I'm not sure whether I correctly used cv::cuda::GpuMat to store image data.

I am highly motivated to test any ideas of you comment at this article,
so please let me know if you have any possible solutions.

Thank you.

Is img.ptr() a valid pointer? I wonder whether a previous memory allocation could have failed without a proper check in place, causing a failure later when trying to bind a texture to non-existent memory.