【问题标题】:Hello World CUDA compilation issuesHello World CUDA 编译问题
【发布时间】:2014-07-19 14:42:55
【问题描述】:

我正在使用 CUDA by Example 一书并尝试编译本书中的第一个 real 示例。我在 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.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$ 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;
}

我还测试了/Developer/NVIDIA/CUDA-6.0/samples/1_Utilities/deviceQuery 示例,它构建并运行良好。

非常感谢任何帮助!蒂亚!

【问题讨论】:

    标签: c++ c macos cuda nvcc


    【解决方案1】:

    将你的文件重命名为hello.cu

    nvcc by default.c.cpp 文件直接发送到主机编译器,而不对其进行任何设备代码检查或编译。

    有各种options 可以改变这种行为。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-24
      • 1970-01-01
      • 2012-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多