[問題] 初學CUDA5.0 + VC2012 <<< 語法錯誤?

看板C_and_CPP (C/C++)作者 (LDPC)時間12年前 (2013/07/16 22:10), 編輯推噓0(004)
留言4則, 2人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) visual c++ 2012 express for windows desktop 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) cuda 5.0 + toolkit SDK (Nsight Visual Studio Edition 3.0 這個東西要安裝嗎?) 問題(Question): 我在嘗試hello world 但是 說 <<< 語法錯誤 我主要設定是參考 http://www.aimantarek.com/2011/01/how-to-make-new-cuda-project-in-vs-2010.html 這篇文章 餵入的資料(Input): #include "stdafx.h" #include< stdio.h> #include "cuda_runtime.h" #include "device_launch_parameters.h" #define N 7 __global__ void add_arrays(char *a, int *b) { a[threadIdx.x] += b[threadIdx.x]; } int main() { // Setup the arrays char a[N] = "Hello "; int b[N] = {15, 10, 6, 0, -11, 1,0}; char *ad; int *bd; const int csize = N*sizeof(char); const int isize = N*sizeof(int); // print the contents of a[] printf("%s", a); // Allocate and Transfer memory to the device cudaMalloc( (void**)&ad, csize ); cudaMalloc( (void**)&bd, isize ); cudaMemcpy( ad, a, csize, cudaMemcpyHostToDevice ); cudaMemcpy( bd, b, isize, cudaMemcpyHostToDevice ); // Perform the array addition dim3 dimBlock( N ); dim3 dimGrid ( 1 ); add_arrays<<<dimGrid, dimBlock>>>(ad, bd); 按f5這個地方說語法錯誤 // Copy the Contents from the GPU cudaMemcpy( a, ad, csize, cudaMemcpyDeviceToHost ); cudaFree( ad ); // Display the results printf("%s\n", a); return 0; } 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): 程式碼(Code):(請善用置底文網頁, 記得排版) 補充說明(Supplement): 我看到說 cuda_vs_wizard已經不能用 請問還有什麼最新說明 適合 初學者呢? 搞了幾天的環境設定....Orz 目前是CUDA 5.0 + VS express 2012 + toolkit SDK 加一大堆設定.... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 112.104.108.19

07/17 10:13, , 1F
你看一下檔案屬性,型別是不是CUDA C/C++
07/17 10:13, 1F

07/18 01:34, , 2F
cuda 5.0 並不支援 vc110, 需要更改props/target等檔案
07/18 01:34, 2F

07/18 01:34, , 3F
沒記錯nsight看個人需求可裝可不裝
07/18 01:34, 3F

07/18 01:36, , 4F
google一下有人釋出修改好得MSBuild檔案可以直接用
07/18 01:36, 4F
文章代碼(AID): #1HvLHUXT (C_and_CPP)
文章代碼(AID): #1HvLHUXT (C_and_CPP)