I tried to compile the following code where I use Eigen and cuda at the same time and I get an error.
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <iostream>
#include <Eigen/Dense>
#include <Eigen/IterativeLinearSolvers>
__global__ void printWithCUDA()
{
if (threadIdx.x == 0)
{
printf(" Printed with thread %d \n", threadIdx.x);
}
}
int main()
{
// Eigen Operation
Eigen::Matrix3d eigenA;
eigenA << 1, 2, 3,
4, 5, 6,
7, 8, 9;
Eigen::Matrix3d eigenB;
eigenB << -1, -2, -3,
-4, -5, -6,
-7, -8, -9;
Eigen::MatrixXd eigenC = eigenA * eigenB;
std::cout << " \n Eigen Matrix " << std::endl;
std::cout << eigenC;
// CUDA Operation
printWithCUDA <<< 1, 32 >>>();
if (cudaPeekAtLastError() != cudaSuccess)
{
fprintf(stderr, "addWithCuda failed!");
return 1;
}
return 0;
}
With VS 2017, Eigen v3.3.4 and CUDA 9.0, I get the following error
eigen\src/Core/util/Macros.h(402): fatal error C1017: invalid integer constant expression
Macros.h(402): fatal error C1017
In my original project, the Eigen code is separated in a .h file from cuda code but the error is the same.
PS: it works well
- if I comment the eigen part, or
- I use Eigen in a fully cpp project with VS 2017 without nvcc
Is this specific to VS2017 + CUDA 9.0 + Eigen v3.3.4 ? Because according to Compiling Eigen library with nvcc (CUDA) : update2 it worked for other verions.
Thanks
Update1:
Thanks Avi Ginsburg, I have downloaded the latest version of dev branch. With that version, I don't get this error anymore. However, I have other errors that I don't understand: I have just replaced the latest stable release version with the one here The unstable source code from the development branch The full error is available in the image here Error_Compil but it looks like this
1>kernel.cu 1>g:\librray_quant\issues_lib\eigen_nvcc\eigen_nvcc\3rdparties\dev_branch\eigen\src/SVD/JacobiSVD.h(614): error C2244: 'Eigen::JacobiSVD::allocate': unable to match function definition to an existing declaration 1>g:\librray_quant\issues_lib\eigen_nvcc\eigen_nvcc\3rdparties\dev_branch\eigen\src/SVD/JacobiSVD.h(613): note: see declaration of 'Eigen::JacobiSVD::allocate' 1>g:\librray_quant\issues_lib\eigen_nvcc\eigen_nvcc\3rdparties\dev_branch\eigen\src/SVD/JacobiSVD.h(614): note: definition 1>g:\librray_quant\issues_lib\eigen_nvcc\eigen_nvcc\3rdparties\dev_branch\eigen\src/SVD/JacobiSVD.h(614): note: 'void Eigen::JacobiSVD::allocate(::Eigen::SVDBase>::Index,Eigen::SVDBase::Index,unsigned int)' 1>g:\librray_quant\issues_lib\eigen_nvcc\eigen_nvcc\3rdparties\dev_branch\eigen\src/SVD/JacobiSVD.h(614): note: existing declarations 1>g:\librray_quant\issues_lib\eigen_nvcc\eigen_nvcc\3rdparties\dev_branch\eigen\src/SVD/JacobiSVD.h(614): note: 'void Eigen::JacobiSVD::allocate(Eigen::SVDBase::Index,Eigen::SVDBase::Index,unsigned int)'