【发布时间】:2018-01-19 12:41:25
【问题描述】:
我尝试编译以下代码,同时使用 Eigen 和 cuda,但出现错误。
#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;
}
使用 VS 2017、Eigen v3.3.4 和 CUDA 9.0,我收到以下错误
eigen\src/Core/util/Macros.h(402): 致命错误 C1017: 无效的整数常量表达式
Macros.h(402): fatal error C1017
在我的原始项目中,Eigen 代码在 .h 文件中与 cuda 代码分开,但错误是相同的。
PS:效果不错
- 如果我评论特征部分,或者
- 我在没有 nvcc 的 VS 2017 的完全 cpp 项目中使用 Eigen
这是特定于 VS2017 + CUDA 9.0 + Eigen v3.3.4 的吗?因为根据Compiling Eigen library with nvcc (CUDA) : update2 它适用于其他版本。
谢谢
更新1:
感谢 Avi Ginsburg,我已经下载了最新版本的 dev 分支。使用该版本,我不再收到此错误。 但是,我还有其他不明白的错误:我刚刚用The unstable source code from the development branch这里的那个替换了最新的稳定版本 完整的错误在图片中可用Error_Compil 但看起来像这样
1>kernel.cu 1>g:\librray_quant\issues_lib\eigen_nvcc\eigen_nvcc\3rdparties\dev_branch\eigen\src/SVD/JacobiSVD.h(614): 错误 C2244: 'Eigen::JacobiSVD::allocate': 无法将函数定义与现有声明 1>g:\librray_quant\issues_lib\eigen_nvcc\eigen_nvcc\3rdparties\dev_branch\eigen\src/SVD/JacobiSVD.h(613):注意:见“Eigen::JacobiSVD::allocate”的声明 1>g:\librray_quant\issues_lib\eigen_nvcc\eigen_nvcc\3rdparties\dev_branch\eigen\src/SVD/JacobiSVD.h(614):注意:定义 1>g:\librray_quant\issues_lib\eigen_nvcc\eigen_nvcc\3rdparties\dev_branch\eigen\src/SVD/JacobiSVD.h(614): 注意:'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):注意:现有声明 1>g:\librray_quant\issues_lib\eigen_nvcc\eigen_nvcc\3rdparties\dev_branch\eigen\src/SVD/JacobiSVD.h(614): 注意:'void Eigen::JacobiSVD::allocate(Eigen::SVDBase::Index, Eigen::SVDBase::Index,unsigned int)'
【问题讨论】:
标签: cuda visual-studio-2017 eigen nvcc