Skip to content

CudaImage allocate error in my project (segmentation fault) #84

@richard-elvira

Description

@richard-elvira

Hi, i am working with this library, and I am already running the examples without problem.

My main problem is to integrate CudaSift in my project, I have add the CudaSIFT code and run well, but problem comes when I try to allocate an image in the CudaImage container where system launch a segmentation fault inside of allocate function.

I send you the code to see if there is something I am missing:

InitCuda(0); // Initialize with the device 0 (from all the devices with CUDA)

if(img.empty())
{
    std::cerr << "Empty image in CudaSiftHandler::extractCudaSift" << std::endl;
}

cv::Mat img_32f;
img.convertTo(img_32f, CV_32FC1, 1/255.0);

unsigned int w = img_32f.cols;
unsigned int h = img_32f.rows;
std::cout << "img_32f cols: " << w << "; rows: " << h << "; channels: " << img_32f.channels() << std::endl;
std::cout << "img_32f type: " << img_32f.type() << std::endl;

mCudaImg.Allocate(w, h, w, false, static_cast<float*>(NULL), (float*)img_32f.data);
mCudaImg.Download();

InitSiftData(mSiftDataImgExt, mnMaxFeatures, true, true);

ExtractSift(mSiftDataImgExt, mCudaImg, mnNumOctaves, mfInitBlur, mfThreshold, mnMinScale, false);
std::cout << "There are " << mSiftDataImgExt.numPts << " sift points detected by GPU" << std::endl;

The output of my code before of the segmentation fault shows that InitCuda has initialized the graphic card correctly, the image is not empty and has the correct format (float):

Device Number: 0
Device name: NVIDIA TITAN Xp
Memory Clock Rate (MHz): 5705
Memory Bus Width (bits): 384
Peak Memory Bandwidth (GB/s): 547.7

img_32f cols: 1440; rows: 1080; channels: 1
img_32f type: 5

Disassembler (at the beginning of Allocate code, in line 5):

0x5555555644f0                  f3 0f 1e fa                       endbr64
0x5555555644f4  <+    4>        53                                push   %rbx
0x5555555644f5  <+    5>        48 89 fb                          mov    %rdi,%rbx
0x5555555644f8  <+    8>        48 83 ec 10                       sub    $0x10,%rsp
0x5555555644fc  <+   12>        89 37                             mov    %esi,(%rdi)   <---- This arise the error.
0x5555555644fe  <+   14>        89 57 04                          mov    %edx,0x4(%rdi)
0x555555564501  <+   17>        c5 fa 7e 4c 24 20                 vmovq  0x20(%rsp),%xmm1
0x555555564507  <+   23>        c4 c3 f1 22 c1 01                 vpinsrq $0x1,%r9,%xmm1,%xmm0
0x55555556450d  <+   29>        89 4f 08                          mov    %ecx,0x8(%rdi)
0x555555564510  <+   32>        48 c7 47 20 00 00 00 00           movq   $0x0,0x20(%rdi)
0x555555564518  <+   40>        c5 f8 11 47 10                    vmovups %xmm0,0x10(%rdi)
0x55555556451d  <+   45>        4d 85 c9                          test   %r9,%r9
0x555555564520  <+   48>        74 4e                             je     0x555555564570 <_ZN9CudaImage8AllocateEiiibPfS0_+128>
0x555555564522  <+   50>        48 83 7c 24 20 00                 cmpq   $0x0,0x20(%rsp)
0x555555564528  <+   56>        75 05                             jne    0x55555556452f <_ZN9CudaImage8AllocateEiiibPfS0_+63>
0x55555556452a  <+   58>        45 84 c0                          test   %r8b,%r8b
0x55555556452d  <+   61>        75 11                             jne    0x555555564540 <_ZN9CudaImage8AllocateEiiibPfS0_+80>
0x55555556452f  <+   63>        48 83 c4 10                       add    $0x10,%rsp
0x555555564533  <+   67>        5b                                pop    %rbx
0x555555564534  <+   68>        c3                                retq

Thanks for the help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions