Ask Your Question

drcurtis's profile - activity

2012-09-18 03:11:25 -0500 received badge  Student (source)
2012-08-28 03:35:53 -0500 received badge  Teacher (source)
2012-08-26 02:56:11 -0500 received badge  Self-Learner (source)
2012-08-25 19:12:06 -0500 answered a question BruteForceMatcher_GPU error on large set of descriptors

I will attempt to answer my own question. This is from a forum at Tom's Hardware:

This mechanism can be disabled (for debugging purposes) by adding a REG_DWORD named TdrLevel to the registry at: HKLM\System\CurrentControlSet\Control\GraphicsDrivers and assigning it a value of '0'. Doing this will simply stop the TDR from resetting your display driver (this may simply tell your computer to allow itself to freeze instead, read on).

Another thing you can try (for debugging purposes) is adding a REG_DWORD named TdrDelay instead of the TdrLevel entry. This entry specifies the number of seconds that the TDR will wait before resetting the GPU/Driver. The default value is 2 seconds, so you can up to to 4 or 10 seconds to see if your system regains responsiveness. Don't leave it at the default value of '0' that's put in when you create the key.

Keep in mind that in most cases these registry entries will not be there and you will have to create them. NEVER mess with the registry if you don't know what you are doing.

To remove the keys (after debugging), simply use the Find function and match it to TdrLevel or TdrDelay and delete the entry.

Source: http://www.microsoft.com/whdc/devi [...] t.mspx#E1B

2012-08-24 11:44:51 -0500 commented answer BruteForceMatcher_GPU error on large set of descriptors

This is in 64-bit Windows 7. Would it be the same limit? If so, is there a way to overcome it? Thanks

2012-08-20 06:14:32 -0500 commented answer BruteForceMatcher_GPU error on large set of descriptors

It crashes within a couple of seconds of starting, so unless it is on a really short leash I don't think that is the issue. I would imagine there is some sort of memory block size limit I am hitting.

2012-08-18 09:35:57 -0500 received badge  Editor (source)
2012-08-18 09:28:39 -0500 asked a question BruteForceMatcher_GPU error on large set of descriptors

I have been successfully using BruteForceMatcher_GPU to match SIFT descriptors from two images. They are 128 dimensional vectors in gpumat form. I can send approximately 35000 from each set, for a total of around 70000 with no problems. Above that, the GPU will crash (black screen, resets).

I get this error: OpenCV Error: Gpu API call (unknown error) in unknown function, file c:/opencv/modules/gpu/src/cuda/bf_match.cu, line 190.

Line 190 is in this function:

 template <int BLOCK_SIZE, typename Dist, typename T, typename Mask>
    void match(const DevMem2D_<T>& query, const DevMem2D_<T>* trains, int n, const Mask& mask,
               const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance,
               cudaStream_t stream)
    {
        const dim3 block(BLOCK_SIZE, BLOCK_SIZE);
        const dim3 grid(divUp(query.rows, BLOCK_SIZE));

        const size_t smemSize = (3 * BLOCK_SIZE * BLOCK_SIZE) * sizeof(int);

        match<BLOCK_SIZE, Dist><<<grid, block, smemSize, stream>>>(query, trains, n, mask, trainIdx.data, imgIdx.data, distance.data);
        cudaSafeCall( cudaGetLastError() );

        if (stream == 0)
            cudaSafeCall( cudaDeviceSynchronize() );
    }

Line 190 is the cudaSafeCall( cudaDeviceSynchronize() ); at the end.

Occasionally it will point to an error here, instead,in gpumat.cpp:

void copy(const GpuMat& src, Mat& dst) const
    {
        cudaSafeCall( cudaMemcpy2D(dst.data, dst.step, src.data, src.step, src.cols * src.elemSize(), src.rows, cudaMemcpyDeviceToHost) );
    }

I can get around this by breaking my image into smaller slices to keep the descriptor count below that threshold.

I have a GeForce GTX670 with 4GB of memory. When sending 400000 descriptors I will use about 1.2GB of that memory.

The code in my program looks like this:

cv::gpu::BruteForceMatcher_GPU< cv::L2<float> > matcher; 

vector<cv::DMatch> matches;
matcher.match(descriptors1GPU, descriptors2GPU, matches);

Any suggestions?