Skip to content

Segfault with command line matcher tools #7

Closed

Description

@QuantumEntangledAndy

Running the command line tools sequential_matcher, or vocab_tree_matcher, and I presume the other matchers too, fails with a seqmentation fault.

*** Aborted at 1462060976 (unix time) try "date -d @1462060976" if you are using GNU date ***
PC: @     0x7fff9aee3c30 glGetString
*** SIGSEGV (@0x3b0) received by PID 61514 (TID 0x700000081000) stack trace: ***
    @     0x7fff9164c52a _sigtramp
    @        0x106656010 glewIsSupported
    @        0x1066289b1 glewInit
    @        0x1059b1e2d GlobalUtil::InitGLParam()
    @        0x1059ce339 SiftMatchGL::InitSiftMatch()
    @        0x1059d0022 SiftMatchGPU::_VerifyContextGL()
    @        0x10573202f colmap::FeatureMatcher::SetupWorkers()
    @        0x1057319c6 colmap::FeatureMatcher::run()
    @        0x1074e857a QThreadPrivate::start()
    @     0x7fff90e1c99d _pthread_body
    @     0x7fff90e1c91a _pthread_start
    @     0x7fff90e1a351 thread_start

Some notes about the build and system:

  • This is on my mac osx 10.11
  • Using the latest source.
  • The GUI version runs fine without fault.
  • CUDA is version 7.5.
  • CUDA was successfully detected by cmake, and enabled.

I did some digging and got it working for me, but I wonder if I missed something, that lets me avoid all this.

The following is my digging, I hope it is useful:
This seems to be caused by line 388 in src/ext/SiftGPU/GlobalUtil.cpp

const char * vendor = (const char * )glGetString(GL_VENDOR);

It seems that a glContext is not initialised.

If I initialise a glContext using SiftGPU's own methods:

sift_gpu_->CreateContextGL();
sift_match_gpu_->CreateContextGL();

Just after line 153 of src/base/feature_matching.cc
The code then runs from the command line without fault. It does briefly produce a window, which may fail on servers but this was the only way I could get any data.

I should note that although cmake enabled CUDA, SiftGPU may be disabling it for macs, given that SiftGPU's cmake contains the following on line 52 of src/ext/SiftGPU/CMakeLists.txt.

if(CUDA_ENABLED AND NOT APPLE)

Activity

  1. ahojnnes commented on May 1, 2016

    @ahojnnes
    Contributor

    Hi Andrew,

    Thanks for reporting!

    Unfortunately, I upgraded to the latest Macbook Pro series some time ago which ships without an Nvidia card, so I cannot check CUDA support on OSX anymore. I will try to find a suitable machine over the next days to fix this and will follow up with you here.

    Thanks again.

    Cheers,
    Johannes

  2. ahojnnes commented on May 21, 2016

    @ahojnnes
    Contributor

    I could not reproduce this issue here. Can you share your specific Hardware?

  3. QuantumEntangledAndy commented on May 21, 2016

    @QuantumEntangledAndy
    Author

    Hmm that's interesting, an un-reproducable one.
    Anyways here are my details not sure which part you would be interested in

    • OS
    osX El-Capitain  10.11.4
    
    • Model
      Model Name:   MacBook Pro
      Model Identifier: MacBookPro9,1
    
    • CPU
      Processor Name:   Intel Core i7
      Processor Speed:  2.3 GHz
      Number of Processors: 1
      Total Number of Cores:    4
      L2 Cache (per Core):  256 KB
      L3 Cache: 6 MB
    
    • RAM
      Memory:   16 GB
      Size: 2  x 8 GB
      Type: DDR3
      Speed:    1600 MHz
    
    • GPU
      Chipset Model:    NVIDIA GeForce GT 650M
      Type: GPU
      Bus:  PCIe
      PCIe Lane Width:  x8
      VRAM (Total): 512 MB
      Vendor:   NVIDIA (0x10de)
    

    I will recompile with the latest code and see if its been squashed since then by another commit.
    Hope all goes well, let me know if you'd like anything else from me.

  4. QuantumEntangledAndy commented on May 21, 2016

    @QuantumEntangledAndy
    Author

    Ok here the the retest results:

    Summary

    • Doesn't work with CUDA enabled resulting in a segfault
    • Does work with CUDA disabled

    Details

    I will layout all of my steps so this may be a long one

    With CUDA enabled

    git clone https://github.com/colmap/colmap/ 01_Test
    cd  01_Test
    

    set up LocalConfig.cmake to include

    set(Qt5_CMAKE_DIR "/usr/local/opt/qt5/lib/cmake")
    set(Qt5Core_DIR ${Qt5_CMAKE_DIR}/Qt5Core)
    set(Qt5OpenGL_DIR ${Qt5_CMAKE_DIR}/Qt5OpenGL)
    
    mkdir build && cd build
    cmake ..
    make
    

    Build succeeds and cmake detects CUDA, cu files are built with nvcc

    Now to test:
    images come from http://zhuoliang.me/gargoyle.zip which is from this page http://zhuoliang.me/meshrecon.html

    mkdir test
    src/exe/database_creator --General.database_path "test/colmap.db"
    src/exe/feature_extractor --General.database_path "test/colmap.db" --General.image_path "gargoyle"
    src/exe/sequential_matcher" --General.database_path "test/colmap.db"
    

    The following segfault occurs when running sequential_matcher

    *** Aborted at 1463834627 (unix time) try "date -d @1463834627" if you are using GNU date ***
    PC: @     0x7fff95051c30 glGetString
    *** SIGSEGV (@0x3b0) received by PID 16919 (TID 0x700000081000) stack trace: ***
        @     0x7fff8b7ba52a _sigtramp
        @        0x1082e5010 glewIsSupported
        @        0x1082b79b1 glewInit
        @        0x1076295fd GlobalUtil::InitGLParam()
        @        0x107645af9 SiftMatchGL::InitSiftMatch()
        @        0x1076477e2 SiftMatchGPU::_VerifyContextGL()
        @        0x10734a73f colmap::FeatureMatcher::SetupWorkers()
        @        0x10734a0d6 colmap::FeatureMatcher::run()
        @        0x10916757a QThreadPrivate::start()
        @     0x7fff8af8a99d _pthread_body
        @     0x7fff8af8a91a _pthread_start
        @     0x7fff8af88351 thread_start
    

    With CUDA disabled

    Same set up as above except now cloned to a fresh directory:

    git clone https://github.com/colmap/colmap/ 02_Test_NOCUDA
    

    and the cmake command is

    cmake -DCUDA_ENABLED=0 ..
    

    Testing:
    Same images etc

    mkdir test
    src/exe/database_creator --General.database_path "test/colmap.db"
    src/exe/feature_extractor --General.database_path "test/colmap.db" --General.image_path "gargoyle"
    src/exe/sequential_matcher" --General.database_path "test/colmap.db"
    

    Succeeds printing out

    ==============================================================================
    Sequential feature matching
    ==============================================================================
    
    Matching image [1/23] in 0.000s
    Matching image [2/23] in 0.789s
    Matching image [3/23] in 0.599s
    Matching image [4/23] in 0.692s
    Matching image [5/23] in 0.875s
    Matching image [6/23] in 1.447s
    Matching image [7/23] in 1.444s
    

    Debuging

    To debug further I put the code (with CUDA enabled) into Xcode using

    cd  01_Test
    mkdir xcode && cd xcode
    cmake -G Xcode ..
    

    Opening in xcode and running with the debugger attached catches the segfault at:

    01_Test/src/ext/SiftGPU/GlobalUtil.cpp: Line 384
    which reads:

    //first time in this function
    glewInit();
    

    throwing a EXC_BAD_ACCESS
    I believe this is occurring because there is no active GLContex at this point and the Mac CUDA version must be relying on it. Which is hinted at in the siftGPU manual, albeit for all GPU implementations not just mac, http://www.cs.unc.edu/~ccwu/siftgpu/manual.pdf on page 6.

    When you tested this on a mac with CUDA, was CUDA successfully detected by cmake i.e. is CUDA in the PATH and DYLD_LIBRARY_PATH, like this:

    export PATH=/Developer/NVIDIA/CUDA-7.5/bin:$PATH
    export DYLD_LIBRARY_PATH=/Developer/NVIDIA/CUDA-7.5/lib:$DYLD_LIBRARY_PATH
    

    Sorry I just find it surprising that you didn't observe this, and thought I should ask just in case.

    A fix that works for me

    Again if I explicitly initialise the GLContext then the program works fine, which I tested by making this alteration to call SiftGPU::CreateContextGL. in FeatureMatching.cc line on 155

    sift_gpu_->CreateContextGL();
    sift_match_gpu_->CreateContextGL();
    

    If you'd like I could create a pull request with the changes I made that got the program working for me. I just don't have another build machine to test the changes on and see if it breaks other OS's.

    Anyway hope all this helps, sorry if it's a bit too much info
    Best Regards
    Andy

  5. ahojnnes commented on May 23, 2016

    @ahojnnes
    Contributor

    Thanks for the detailed traceback!

    Can you try to change L52 in src/ext/SiftGPU/CMakeLists.txt from:

    if(CUDA_ENABLED AND NOT APPLE)
    

    to

    if(CUDA_ENABLED)
    

    and check if that solves the problem?

  6. QuantumEntangledAndy commented on May 25, 2016

    @QuantumEntangledAndy
    Author

    I pulled your latest version, with the changed

    if(CUDA_ENABLED)
    

    After which the program successfully compiled and ran without any further changes.
    I will let you know if I find anything else but you can probably close :).

  7. ahojnnes commented on May 25, 2016

    @ahojnnes
    Contributor

    Thanks Andrew for your efforts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions