strasdat / ScaViSLAM

This is a general and scalable framework for visual SLAM. It employs "Double Window Optimization" (DWO).
GNU Lesser General Public License v3.0
334 stars 132 forks source link

CMake bugs and CUDA issues in Ubuntu 12.04 #37

Open kevinmpeterson opened 11 years ago

kevinmpeterson commented 11 years ago

I ran into a couple of issues when building under Ubuntu 12.04 LTS. I'm running an essentially stock setup. I'm using CUDA 5.0. I followed the install directions exactly (copy-paste into terminal).

Two problems:

1) Build failed with complaints about errors finding cudi* (e.g., cu_di_sfree, cu_di_add, etc). Also complained about inability to link gluSphere and gluDisk.

Resolution: I added GLU and cxsparse to line 67 in ScaViSLAM/CMakeLists.txt. The line now reads:

SET (LIB_NAMES GL GLU pangolin glut g2o_stuff g2o_core g2o_solver_csparse csparse cxsparse

2) CUDA 5 does not include cutil_inline.h. Since this is missing, stereo_slam.cpp is broken.

I commented out the include for cutil_inline.h in stereo_slam.cpp and added an include for cuda_runtime_api.h for cudaGetDeviceProperties.

CUDA_SAFE_CALL is a macro and needs to be replaced. If I had lots of time, I would fix this a nice way (e.g., write a nice macro and put it in a .h), but instead I just replaced the call to around CUDA_SAFE_CALL (line 664ish in stereo_slam.cpp) with the following code:

#ifdef SCAVISLAM_CUDA_SUPPORT
  cudaDeviceProp prop;

  {
      cudaError err = cudaGetDeviceProperties(&prop, 0);
      if(err != cudaSuccess) {
          std::cerr << "Cuda error in file '" << __FILE__
              << "' in line " << __LINE__
              << " : " << cudaGetErrorString( err )
              << "." << std::endl;
            exit(EXIT_FAILURE);
        }
  }

  {
      cudaError err = cudaThreadSynchronize();
      if(err != cudaSuccess) {
          std::cerr << "Cuda error in file '" << __FILE__
              << "' in line " << __LINE__
              << " : " << cudaGetErrorString( err )
              << "." << std::endl;
          exit(EXIT_FAILURE);
      }
  }

  std::cout << "Multiprocessors: " << prop.multiProcessorCount << std::endl;
#endif

Google tells me that this macro has been moved into some other file (helper_cuda.h), but for whatever reason my install of CUDA doesn't seem to have that file.

Now everything builds. Hope this helps someone else.

romulogcerqueira commented 10 years ago

It works for me. Thank you!

asimay commented 9 years ago

my opencv cannot compile through under having CUDA environment... why?

asimay commented 9 years ago

I solved the problem, opencv is not work with CUDA 6.5, this is opencv bug, it is already resolved. please see detail info belows. http://code.opencv.org/projects/opencv/repository/revisions/feb74b125d7923c0bc11054b66863e1e9f753141

asimay commented 9 years ago

hi, dear kevinmpeterson, I have CUDA setup successfully, and with GeForce GT730 Nvidia card, but the frame rate is still very low, like above. what's the reason of it? can you help me? thanks. my computer status: ubuntu 14.04 LTS GeForce GT730 Nvidia card; CUDA 6.5 opencv 2.4.9

2014-09-30 21 10 25