C++ Hello World CUDA编译问题
我正在使用CUDA的示例书,并试图编译书中的第一个真实示例。我在OSX 10.9.2上: 我的消息来源是:C++ Hello World CUDA编译问题,c++,c,macos,cuda,nvcc,C++,C,Macos,Cuda,Nvcc,我正在使用CUDA的示例书,并试图编译书中的第一个真实示例。我在OSX 10.9.2上: 我的消息来源是: @punk ~/Documents/Projects/CUDA$ /Developer/NVIDIA/CUDA-6.0/bin/nvcc hello.c nvcc warning : The 'compute_10' and 'sm_10' architectures are deprecated, and may be removed in a future release. hello
@punk ~/Documents/Projects/CUDA$ /Developer/NVIDIA/CUDA-6.0/bin/nvcc hello.c
nvcc warning : The 'compute_10' and 'sm_10' architectures are deprecated, and may be removed in a future release.
hello.c:6:1: error: unknown type name '__global__'
__global__ void kernel(void) {
^
hello.c:6:12: error: expected identifier or '('
__global__ void kernel(void) {
^
hello.c:10:3: error: use of undeclared identifier 'kernel'
kernel<<<1,1>>>();
^
hello.c:10:11: error: expected expression
kernel<<<1,1>>>();
^
hello.c:10:17: error: expected expression
kernel<<<1,1>>>();
^
hello.c:10:19: error: expected expression
kernel<<<1,1>>>();
^
6 errors generated.
@punk~/Documents/Projects/CUDA$/Developer/NVIDIA/CUDA-6.0/bin/nvcc hello.c
nvcc警告:“compute_10”和“sm_10”体系结构已被弃用,可能会在将来的版本中删除。
您好。c:6:1:错误:未知类型名称“\uuuu global\uuuuu”
__全局无效内核(void){
^
hello.c:6:12:错误:应为标识符或'('
__全局无效内核(void){
^
hello.c:10:3:错误:使用了未声明的标识符'kernel'
内核();
^
您好。c:10:11:错误:预期表达式
内核();
^
您好。c:10:17:错误:预期表达式
内核();
^
您好。c:10:19:错误:预期表达式
内核();
^
生成6个错误。
我的消息来源很简单:
punk ~/Documents/Projects/CUDA$ cat hello.c
#include <cuda.h>
#include <stddef.h>
#include <stdio.h>
//#include "common/book.h"
__global__ void kernel(void) {
}
int main(void) {
kernel<<<1,1>>>();
printf("oh hai\n");
return 0;
}
punk~/Documents/Projects/CUDA$cat hello.c
#包括
#包括
#包括
//#包括“common/book.h”
__全局无效内核(void){
}
内部主(空){
内核();
printf(“oh hai\n”);
返回0;
}
我还测试了/Developer/NVIDIA/CUDA-6.0/samples/1_Utilities/deviceQuery
示例,该示例构建并运行良好
非常感谢您的帮助!TIA!将您的文件重命名为
hello.cu
nvcc将.c
或.cpp
文件直接发送到主机编译器,而不进行任何设备代码检查或编译
有多种方法可以改变这种行为