Ask Your Question
1

BruteForceMatcher_GPU error on large set of descriptors

asked 2012-08-18 09:28:39 -0500

drcurtis gravatar image

updated 2012-08-18 09:37:06 -0500

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?

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
2

answered 2012-08-25 19:12:06 -0500

drcurtis gravatar image

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

edit flag offensive delete link more
1

answered 2012-08-19 13:46:17 -0500

Vladislav Vinogradov gravatar image

Driver can interrupt a function if it takes two long. Maybe that's the problem.

edit flag offensive delete link more

Comments

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.

drcurtis gravatar imagedrcurtis ( 2012-08-20 06:14:32 -0500 )edit

Individual kernels are limited to a 2-second runtime by Windows Vista.

Vladislav Vinogradov gravatar imageVladislav Vinogradov ( 2012-08-24 03:34:12 -0500 )edit

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

drcurtis gravatar imagedrcurtis ( 2012-08-24 11:44:51 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2012-08-18 09:28:39 -0500

Seen: 1,044 times

Last updated: Aug 25 '12