Thrust(CUDA 库)编译错误,如““vectorize_from_shared_kernel__entry” : 不是“thrust::detail::device::cuda”的成员

发布于 2024-08-24 16:48:44 字数 2407 浏览 1 评论 0原文

我使用 CUDA VS Wizard 创建一个 VS 项目,并尝试使用 Thrust 构建一个 cuda 程序,测试程序非常简单:

// ignore headers
int main(void)
{
 thrust::device_vector<double> X;
 X.resize(100);
}

我会得到一些编译错误,例如:

1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(29) :错误 C2039:'vectorize_from_shared_kernel__entry':不是成员 '推力::细节::设备::cuda' 1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(29) :错误 C2039:'vectorize_from_shared_kernel__entry':不是成员 '推力::细节::设备::cuda' 1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(29) :错误 C2065:'vectorize_from_shared_kernel__entry':未声明 标识符 1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(29) :错误 C2062:类型“int”意外 1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(29) :错误 C2039:'vectorize_from_shared_kernel__entry':不是成员 '推力::细节::设备::cuda' 1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(29) :错误 C2039:'vectorize_from_shared_kernel__entry':不是成员 '推力::细节::设备::cuda' 1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(29) :错误 C2065:'vectorize_from_shared_kernel__entry':未声明 标识符 1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(29) :错误 C2062:类型“int”意外 1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(36) :错误 C2143:语法错误:缺少 ';'在“<”之前 1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(36) :错误C2182:'__wrapper__device_stub_vectorize_from_shared_kernel': 非法使用“void”类型 1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(36) :错误C2988:无法识别的模板声明/定义 1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(36) : 错误 C2059: 语法错误 : '<' 1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(38) :错误 C2143:语法错误:缺少 ';'前 '}' 1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(38) :致命错误 C1506:不可恢复的块作用域错误

但是,如果我注释掉第二条语句“X.resize(100);”,它可以成功构建。 所以我猜推力设置、构建规则设置和CUDA设置是正确的。您知道为什么会出现这些编译错误吗?

我正在使用 VS 2008、CUDA 2.3 和 Thrust 1.1。

I create a VS project using CUDA VS Wizard, and I try to build a cuda program using Thrust, the test program is quite simple:

// ignore headers
int main(void)
{
 thrust::device_vector<double> X;
 X.resize(100);
}

I will got some compile error like:

1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(29)
: error C2039: 'vectorize_from_shared_kernel__entry' : is not a member
of 'thrust::detail::device::cuda'
1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(29)
: error C2039: 'vectorize_from_shared_kernel__entry' : is not a member
of 'thrust::detail::device::cuda'
1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(29)
: error C2065: 'vectorize_from_shared_kernel__entry' : undeclared
identifier
1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(29)
: error C2062: type 'int' unexpected
1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(29)
: error C2039: 'vectorize_from_shared_kernel__entry' : is not a member
of 'thrust::detail::device::cuda'
1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(29)
: error C2039: 'vectorize_from_shared_kernel__entry' : is not a member
of 'thrust::detail::device::cuda'
1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(29)
: error C2065: 'vectorize_from_shared_kernel__entry' : undeclared
identifier
1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(29)
: error C2062: type 'int' unexpected
1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(36)
: error C2143: syntax error : missing ';' before '<'
1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(36)
: error C2182: '__wrapper__device_stub_vectorize_from_shared_kernel' :
illegal use of type 'void'
1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(36)
: error C2988: unrecognizable template declaration/definition
1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(36)
: error C2059: syntax error : '<'
1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(38)
: error C2143: syntax error : missing ';' before '}'
1>C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/tmpxft_00003cc0_00000000-3_sample.cudafe1.stub.c(38)
: fatal error C1506: unrecoverable block scoping error

However, if I comment out the second statement "X.resize(100);", it can build successfully.
So I guess the thrust setting, build rule setting and CUDA settings are correct. Do you have any idea about why these compile error appear?

I am using VS 2008, CUDA 2.3 and Thrust 1.1.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愁杀 2024-08-31 16:48:44

这是在 .cu 文件中(用 nvcc 编译)吗?推力代码应放入 .cu 文件中。

顺便说一句,我个人避免使用 CUDA VS 向导(部分原因是 NVIDIA 不提供/支持)并使用 这篇文章

Is this in a .cu file (compiled with nvcc)? Thrust code should be put in .cu files.

Incidentally, personally I avoid the CUDA VS Wizard (partly because it is not provided/supported by NVIDIA) and use the strategy described in this other post.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文