OpenCV + CUDA Unknown error while running

Hello!

I compiled OpenCV 2.4.6.1 using cmake:

cmake -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_CUDA=ON ..

Then I tried to compile a little sample:

#include <iostream>
#include "opencv2/opencv.hpp"
#include "opencv2/gpu/gpu.hpp"

int main (int argc, char* argv[])
{
    try
    {
	cv::Mat src_host;
        //cv::Mat src_host = cv::imread("lena.png", CV_LOAD_IMAGE_GRAYSCALE);
        cv::gpu::GpuMat dst, src;
        src.upload(src_host);

        cv::gpu::threshold(src, dst, 128.0, 255.0, CV_THRESH_BINARY);

        cv::Mat result_host(dst);
        cv::imshow("Result", result_host);
        cv::waitKey();
    }
    catch(const cv::Exception& ex)
    {
        std::cout << "Error: " << ex.what() << std::endl;
    }
    return 0;
}

it was compiled using the following:

g++ -ggdb `pkg-config --cflags opencv` -o `basename opencvtest.cpp .cpp` p.cpp `pkg-config --libs opencv`

When I try to run the program, it gives me:

./opencvtest 
OpenCV Error: Gpu API call (unknown error) in copy, file /home/facu/Documentos/opencv-2.4.6.1/modules/core/src/gpumat.cpp, line 1196
Error: /home/facu/Documentos/opencv-2.4.6.1/modules/core/src/gpumat.cpp:1196: error: (-217) unknown error in function copy

I tried with OpenCV 2.4.8 and 2.4.5, but it always gives me an “unknown error”, i.e: using 2.4.8 I have problems with “mallocPitch”… Also, I changed from CUDA 5.5 to CUDA 5.0(actual)

Do you think it is more convenient to use CUDA 6.0 and the new features, by using NPP library?