nvcc can't compile code that uses Eigen


I am trying to write a CUDA version of a FEM solver that I wrote in C++. Part of the serial code uses the Eigen library (version 3.3). Whenever I compile source file that uses Eigen with nvcc I get the following error:

nvcc -x cu -dc Element.cpp

In file included from /usr/local/cuda-9.0/bin/…//include/common_functions.h:50:0,
from /usr/local/cuda-9.0/bin/…//include/cuda_runtime.h:115,
from :0:
/usr/local/cuda-9.0/bin/…//include/crt/common_functions.h:64:24: error: token ““CUDACC_VER is no longer supported. Use CUDACC_VER_MAJOR, CUDACC_VER_MINOR, and CUDACC_VER_BUILD instead.”” is not valid in preprocessor expressions
#define CUDACC_VER "CUDACC_VER is no longer supported. Use CUDACC_VER_MAJOR, __CUDACC_V
/usr/include/eigen3/Eigen/src/Core/util/Macros.h:364:33: note: in expansion of macro ‘CUDACC_VER
#if defined(CUDACC_VER) && CUDACC_VER >= 70500 && __cplusplus > 199711L

I tried to go to that Macros.h file and replace CUDACC__VER with CUDACC_VER_MAJOR but this replaced the above message with a plethora of Eigen warning messages.

Any idea? I use Eigen for basic linear algebra operations. It’s not used as part of another library. I’m using CUDA 9.0.

I apologize if this issue was already resolved.

Eigen probably needs to be updated for the issue you have here.

In the meantime, one possible suggestion is to put your Eigen code in C/C++ files only, ending in .cpp Put your CUDA code in files ending in .cu Use wrapper functions or whatever else is necessary to tie the two together.

1 Like

Thanks for the reply!

I have the latest (3.3.4) version of eigen.

Part of the cuda code that I intended to write would have each thread use Eigen to perform some of the linear algebra operations (matrix inversion and matrix multiplications) that are needed by the FEM at the element level. The matrices each thread would have to work with are like 10*10.

In the meantime, I’ve been trying to write a serial version that doesn’t use Eigen. Is there another simple linear algebra library that would not conflict with cuda?

Another alternative that I have in mind is to precompute all the matrix inverses on the CPU and send them to the GPU who will do the matrix multiplications element by element.

Hello,I have the same error now. Did you deal with them? Thank you very much.

I wrote an Eigen-free version of my serial code. I’m going to review cuda a little more in depth and adjust my serial code before trying to parallelize it. So I haven’t really fixed that bug, sorry.

I am in the same boat. Trying to compile Caffe with CUDA+CuDNN but stopped by this.

I am too. What to do with this?

I am unable to find a solution that works as of yet and making do with CPU only builds or docker images.

However, changing the C compiler to clang3.x changes the error message to a parsing error in gcc element “Tuple”. That should give a clue.

This is weird.

I assume that someday in the future, Eigen will be updated to be compatible with CUDA 9:


In the meantime, various libraries are using various methods to work around the incompatibility:


Eigen has already been updated for CUDA 9, there just hasn’t been an official release since then. Just grab the latest code form the repository that txbob referenced

Thanks ^. I am able to compile now.
will be testing exhaustively and tell everyone if any glitches.

The clang issue was a separate bug and was fixed in a september commit.