簡體   English   中英

Hello World CUDA編譯問題

[英]Hello World CUDA compilation issues

我正在使用CUDA by Example書籍並嘗試編譯本書中的第一個真實示例。 我在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示例,並且構建並運行正常。

任何幫助是極大的贊賞! TIA!

將文件重命名為hello.cu

nvcc 默認.c.cpp文件直接發送到主機編譯器,而不對它們進行任何設備代碼檢查或編譯。

有多種選項可以更改此行為。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM