CUDA:编译我的第一个 cuda 程序时出错

发布于 2024-10-06 08:08:37 字数 897 浏览 0 评论 0原文

我对 CUDA 编程非常陌生。我编写了第一个代码,当我编译它时,它向我显示了很多错误。谁能告诉我

代码

#include <stdio.h>
#include "cuda.h"
#include <stdlib.h>

__global__ void kernel(void) {
}

int main(int argc, char *argv[])
{
        kernel<<<1,1>>>();
        printf("finished \n");
        return 0;
}

出了什么问题这些错误是

cuda.c:5: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âvoidâ
cuda.c:7: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âvoidâ
cuda.c: In function âmainâ:
cuda.c:12: error: âkernelâ undeclared (first use in this function)
cuda.c:12: error: (Each undeclared identifier is reported only once
cuda.c:12: error: for each function it appears in.)
cuda.c:12: error: expected expression before â<â token

我使用编译的

nvcc cuda.c

谁能告诉我我犯了什么错误......

I am very new to CUDA programming.. I wrote my first code and when I compiled it, it is showing me a lots of error. Can anyone tell me what is wrong

the code

#include <stdio.h>
#include "cuda.h"
#include <stdlib.h>

__global__ void kernel(void) {
}

int main(int argc, char *argv[])
{
        kernel<<<1,1>>>();
        printf("finished \n");
        return 0;
}

The errors are

cuda.c:5: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âvoidâ
cuda.c:7: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âvoidâ
cuda.c: In function âmainâ:
cuda.c:12: error: âkernelâ undeclared (first use in this function)
cuda.c:12: error: (Each undeclared identifier is reported only once
cuda.c:12: error: for each function it appears in.)
cuda.c:12: error: expected expression before â<â token

I compiled using

nvcc cuda.c

Can anyone tell me what mistake I am making....

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

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

发布评论

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

评论(1

迷途知返 2024-10-13 08:08:37

nvcc 通过普通 C 编译器运行 .c 文件。将文件重命名为 cuda.cu

nvcc runs .c files through the normal C compiler. Rename your file to cuda.cu.

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