ICPCUDA icon indicating copy to clipboard operation
ICPCUDA copied to clipboard

Compile Failed (Eigen errors)

Open syedharoonalam opened this issue 8 years ago • 31 comments

Hi, I am getting following Eigen errors when compiling the project:

Error 16 error : calling a host function("Eigen::DenseBase<Eigen::Matrix<float, (int)29, (int)1, (int)2, (int)29, (int)1> > ::Zero") from a device function("blockReduceSum<(int)29> ") is not allowed

Error 73 error : calling a host function("Eigen::DenseCoeffsBase<Eigen::Matrix<float, (int)29, (int)1, (int)2, (int)29, (int)1> , (int)1> ::operator []") from a device function("Reduction::SquareUpperTriangularProduct<(int)0, (int)0, (int)6> ::apply") is not allowed

Error 18 error : calling a host function("Eigen::DenseCoeffsBase<Eigen::Matrix<float, (int)29, (int)1, (int)2, (int)29, (int)1> , (int)1> ::operator []") from a device function("warpReduceSum<(int)29> ") is not allowed

Error 25 error : calling a host function("Eigen::Matrix<float, (int)29, (int)1, (int)2, (int)29, (int)1> ::Matrix") from a device function("Reduction::operator ()") is not allowed

Error 15 error : calling a host function("Eigen::Matrix<float, (int)29, (int)1, (int)2, (int)29, (int)1> ::MatrixEigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<float , Eigen::Matrix<float, (int)29, (int)1, (int)2, (int)29, (int)1> > > ") from a device function("blockReduceSum<(int)29> ") is not allowed

Error 51 error : calling a host function("Eigen::MatrixBase<Eigen::Matrix<float, (int)3, (int)3, (int)2, (int)3, (int)3> > ::operator *<Eigen::Matrix<float, (int)3, (int)1, (int)2, (int)3, (int)1> > ") from a device function("Reduction::operator ()") is not allowed

I have built and installed Eigen from source files (CUDA supported). Tried using both github.com/stevenlovegrove/eigen and Eigen 3.3. Also I have installed Eigen, Pangolin, Sophus and ICPCUDA all in Release mode for x64 platform.

Any suggestions ?

syedharoonalam avatar Jul 29 '16 08:07 syedharoonalam

What OS, version of CUDA and compiler?

mp3guy avatar Jul 29 '16 13:07 mp3guy

Windows 10, CUDA 7.0, VS 2013

syedharoonalam avatar Jul 29 '16 15:07 syedharoonalam

There are some issues with building Eigen within CUDA on Windows, you have to only include the minimal Eigen headers.

mp3guy avatar Jul 29 '16 15:07 mp3guy

I built Eigen with CUDA separately, that part worked. But, calling it in kernal of this project doesn't seems to be working.

syedharoonalam avatar Jul 29 '16 15:07 syedharoonalam

By the way, what is recommended OS, CUDA and compiler for this project ?

I built Eigen again, and now getting error of: declaration is incompatible with "void Eigen::BDCSVD.. and if I comment this template I get attached errors. errors

My guess is its wise to switch OS, please suggest.

syedharoonalam avatar Aug 01 '16 10:08 syedharoonalam

I would switch to Ubuntu, the build has not been fully tested on Windows.

mp3guy avatar Aug 01 '16 13:08 mp3guy

Hi, i've got a similar set of errors on Ubuntu 14.04 LTS, gcc 4.8.4 and CUDA V7.5.17.

home/aslab/pkg/ICPCUDA/src/Cuda/estimate.cu(56): error: calling a _host_ function("Eigen::Matrix<float, (int)29, (int)1, (int)2, (int)29, (int)1> ::operator =") from a _device_ function("blockReduceSum<(int)29> ") is not allowed

I'm wondering if it's because I haven't compiled stevenlovegrove/eigen properly. In the CMake GUI it seems to have found all of the Eigen stuff except for CUDA_SDK_ROOT_DIR - is that a problem? I have checked all of the CUDA-related checkboxes except for CUDA_BUILD_EMULATION which causes a problem.

Then for ICPCUDA in CMake I have set the EIGEN_INCLUDE_DIRS to my local build (since I don't want to overwrite the system Eigen installation with the forked version).

steevo87 avatar Aug 02 '16 04:08 steevo87

CUDA_SDK_ROOT_DIR wont be a problem. Steven mentioned that they used CUDA 8.0 (pre production), you may try with that. If it works please let me know as well. I am shifting from Windows to Ubuntu.

syedharoonalam avatar Aug 02 '16 12:08 syedharoonalam

Thanks for the tip - I tried CUDA 8.0 on a separate partition and it all seems to work well. However, because I hadn't tried CUDA 7.5 on that partition I can't 100% guarantee that it was the version of CUDA that made the difference (though it does seem that way).

steevo87 avatar Aug 09 '16 09:08 steevo87

Hi, similiar Problems over here.

Running Kubuntu 14.04 with cuda 7.5 (nvcc 7.5.17) Error Output is like this:


~/git/ICPCUDA/src/Cuda/pyrdown.cu(149): error: calling a __host__ function("Eigen::Matrix<float, (int)3, (int)1, (int)2, (int)3, (int)1> ::Matrix") from a __global__ function("computeNmapKernel") is not allowed

~/git/ICPCUDA/src/Cuda/pyrdown.cu(149): error: calling a __host__ function("Eigen::Matrix<float, (int)3, (int)1, (int)2, (int)3, (int)1> ::Matrix") from a __global__ function("computeNmapKernel") is not allowed

and so on

Tried Cuda 8.0 with no difference, tried some eigen versions (3.0.0, 3.3-beta1 and some others) with also no success. btw. exp-branch seems to compile but i can't finish the testrun (no assosiations.txt file in the testdate so the test runs an infinite loop)

any idea what this could be about?

axelus111 avatar Aug 09 '16 13:08 axelus111

I have successfully compiled using Ubuntu 14.04 and CUDA 7.5.18. If you are getting EIgen errors, make sure you are building Eigen with CUDA support.

syedharoonalam avatar Aug 10 '16 05:08 syedharoonalam

I just got it working with CUDA 7.5.17 too - it turns out that I need to install (sudo make install) my CUDA-enabled Eigen headers.

I'm not sure why it wouldn't work when I directed Pangolin, Sophus and ICPCUDA to my local CUDA-enabled Eigen headers using the CMake EIGEN3_INCLUDE_DIR field - maybe I missed one of them or re-built them in the wrong order..

steevo87 avatar Aug 11 '16 01:08 steevo87

Hi, I ve got it working to installing eigen in /usr/include instead of /usr/local/include. No matter where i've pointed to the eigen lib in cmake, it has always used the install in /usr/include

axelus111 avatar Aug 11 '16 06:08 axelus111

I am getting these same errors, has anyone successfully compiled this on windows?

antithing avatar Nov 25 '16 10:11 antithing

same problem with CUDA 8.0 ubunto 14.04 Eigen 3.2.0, @steevo87 @syedharoonalam could you tell me how to remake eigen with cuda support ?

wine3603 avatar Mar 15 '17 09:03 wine3603

just found the newest Eigen 3.3.3 involved cuda supporting. As pointed by @axelus111 , no matter where ever you set the eigen dir, it always use the eigen from /usr/include firstly. So either you remove eigen 3.2.0 by sudo apt-get remove libeigen3-dev and then point eigen dir to 3.3.3 in cmake-gui, or install eigen 3.3.3 into /usr/include/ Then remake ICPCUDA , it will pass with a lot of warnings.

wine3603 avatar Mar 17 '17 03:03 wine3603

Hi all, I am on windows, and have Eigen 3.3. I am down to 2 errors, but cannot figure out how to solve them...

Error "operator=" has already been declared in the current scope ICP d:\libs\eigen-eigen-b30b87236a1b\eigen\src\Core\Block.h 111 Error "operator=" has already been declared in the current scope ICP d:\libs\eigen-eigen-b30b87236a1b\eigen\src\Core\Ref.h 155

Does anyone have any ideas here?

Thanks!

antithing avatar Apr 02 '17 18:04 antithing

@syedharoonalam I just ran into the same Eigen problems void Eigen::BDCSVD from windows. The environment: Eigen 3.3.3 (has CUDA support), CUDA 8, Windows 7.

The issue for me was including <Eigen/Geometry> inside CUDA code. As @mp3guy suggested, switching to minimal <Eigen/Core> is the answer.

If you still need Geometry support (as I did), you can wrap the header and comment out the problematic includes (SVD and Geometry/Scaling). This assumes that you are not using them and is really nvcc not properly parsing Eigen's code ( eg. you are not doing SVDs on device)

Anyways, instead of including <Eigen/Geometry> create a file geometry_wrapper.h and do something like:

#ifndef __CUDACC__ 
#  include <Eigen/Geometry> 
#else 
#  ifndef WIN32 	
#    include <Eigen/Geometry> 
#  else //this is the case for CUDA on Windows
     [COPY includes from <Eigen/Geometry> here, and comment out the problematic ones]
#  endif
#endif

This should be okay for all other OS/compilers, as it only changes CUDA on windows.

randi120 avatar May 23 '17 16:05 randi120

@randi120 Could you please post your real geometry_wrapper.h for us?

Buzzroid avatar Jun 22 '17 08:06 Buzzroid

@Buzzroid, I did not run into these problems with ICPCUDA, so I am not sure if you are having issues with the same headers, that's why I did not post the wrapper in the earlier response (it might not be a one-size fits all kind of solution).

But if you think it could be helpful, see below for the geometry_wrapper.h file

#ifndef __CUDACC__ 
#  include <Eigen/Geometry> 
#else 
#  ifndef WIN32 	
#    include <Eigen/Geometry> 
#  else //this is the case for CUDA on Windows
//    RC: the code below code comes from Eigen's 3.3.3 <Eigen/Geometry> 
//    with problematic headers commented out (SVD and Scaling)
//    we are not using either functionality on device but for some reason nvcc tries to parse these headers (at least on windows) and fails.
#    ifndef EIGEN_GEOMETRY_MODULE_H
#      define EIGEN_GEOMETRY_MODULE_H
#      include <Eigen/Core>
#      include <Eigen/src/Core/util/DisableStupidWarnings.h>
//#      include <Eigen/SVD>
#      include <Eigen/LU>
#      include <limits>
#      include <Eigen/src/Geometry/OrthoMethods.h>
#      include <Eigen/src/Geometry/EulerAngles.h>
#      include <Eigen/src/Geometry/Homogeneous.h>
#      include <Eigen/src/Geometry/RotationBase.h>
#      include <Eigen/src/Geometry/Rotation2D.h>
#      include <Eigen/src/Geometry/Quaternion.h>
#      include <Eigen/src/Geometry/AngleAxis.h>
#      include <Eigen/src/Geometry/Transform.h>
#      include <Eigen/src/Geometry/Translation.h>
//#      include <Eigen/src/Geometry/Scaling.h>
#      include <Eigen/src/Geometry/Hyperplane.h>
#      include <Eigen/src/Geometry/ParametrizedLine.h>
#      include <Eigen/src/Geometry/AlignedBox.h>
#      include <Eigen/src/Geometry/Umeyama.h>
#      if defined EIGEN_VECTORIZE_SSE && !defined EIGEN_VECTORIZE_AVX
#        include <Eigen/src/Geometry/arch/Geometry_SSE.h>
#      endif
#      include <Eigen/src/Core/util/ReenableStupidWarnings.h>
#    endif // EIGEN_GEOMETRY_MODULE_H
#  endif
#endif


randi120 avatar Jun 22 '17 15:06 randi120

@randi120 Thanks for the post. I've tried but failed with the same errors.

By the way, it seems that Eigen itself has some issues or bugs. There is a bug report regarding this: http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1412

Buzzroid avatar Jun 22 '17 23:06 Buzzroid

@randi120 Oh, It seems that your solution works.

Here's what I've done:

  • Block including the eigen header files in two places: ICPOdometry.h and Cuda/internal.h
  • Include "geometry_wrapper.h" in the places

Thank @randi120 again.

Buzzroid avatar Jun 22 '17 23:06 Buzzroid

@Buzzroid I am glad it works. Hopefully Eigen fixes that bug (thanks for that, I didn't know about it) and then the wrapper won't be needed.

randi120 avatar Jun 23 '17 01:06 randi120

@randi120 The eigen errors are solved. But I got "undefined symbol 'M_PI' in sophus.hpp". And I have compiled Sophus successfully. My platform: VS2015, CUDA8.0 Could you help me to solve this problem?

polar99 avatar Jul 17 '17 06:07 polar99

@randi120 I am facing the same problem in ubuntu 14.04 and eigen 3.3.4. Can you kindly send a pull request or share your changes in a more detailed manner? I will hugely helpful for people stumbling above on this error.

Thanks Arpit

arpit15 avatar Aug 14 '17 22:08 arpit15

@StephenGreat, I am sure you figured this one out. Sometimes windows gets a little silly You can try adding add_definitions(-D_USE_MATH_DEFINES) to a top-level cmake file.

If that doesn't work, I would modify the source file directly.

#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif

randi120 avatar Aug 14 '17 23:08 randi120

@arpit15, I am hesitant to create a pull request for code I have never used. As I mentioned above, I did not run into these issues with ICPCUDA. However, this thread was one of the top hits, and once I got something to work (on my own code), I figure it would be worth sharing here.

That said, a possible fix for ICPCUDA could be:

  1. create a file geometry_wrapper.h. Paste the code from my earlier post into the file.
  2. (As stated by @Buzzroid) replace the lines #include <Eigen/Geometry> in ICPOdometry.h and Cuda/internal.h with #include "geometry_wrapper.h".

EDIT: I missed the "ubuntu 14.04". Since that is the the case, try changing the line # ifndef WIN32 to # ifdef WIN32. This will include <Eigen/Geometry> on windows (which you don't care about), and Ubuntu should go into the else clause (which is what you care about)

Hope that helps.

randi120 avatar Aug 14 '17 23:08 randi120

@randi120 thanks for the details notes. Unfortunately I am still facing the same error on my system.

arpit15 avatar Aug 15 '17 00:08 arpit15

@axelus111 Thanks for your tips! It works! Just change the CMAKE_INSTALL_PREFIX of eigen from "/usr/local" to "/usr" in the Cmake-GUI and keep the rest unchanged. Then I compile successfully!

RicheyHuang avatar Jan 17 '18 01:01 RicheyHuang

Windows 10, CUDA 7.0, VS 2013

Have you run successfully on VS2017 or VS2015?

Zzj-pcl avatar May 26 '19 14:05 Zzj-pcl