我正在尝试在 64 位 Windows 7 上使用 Visual Studio 2010 Express 在 Windows 上进行 CUDA 编程。我花了一些时间来设置环境,我刚刚编写了我的第一个程序 helloWorld.cu :)
目前我正在使用以下程序:
#include <stdio.h>
__global__ void add(int a, int b, int *c){
*c = a + b;
}
int main(void){
int c;
int *dev_c;
HANDLE_ERROR( cudaMalloc( (void**)&dev_c, sizeof(int) ) );
add<<<1,1>>>(2, 7, dev_c);
HANDLE_ERROR( cudaMemcpy( &c, dev_c, sizeof(int), cudaMemcpyDeviceToHost ) );
printf("2 + 7 = %d\n", c);
cudaFree( dev_c );
return 0;
}
以下是使用 Windows7.1SDK 平台工具集构建的输出:
1> C:\Users\User\documents\visual studio 2010\Projects\CudaTest2\CudaTest2>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -G --keep-dir "x64\Debug" -maxrregcount=0 --machine 64 --compile -g -Xcompiler "/EHsc /W1 /nologo /O2 /Zi /MD " -o "x64\Debug\hello.cu.obj" "C:\Users\User\documents\visual studio 2010\Projects\CudaTest2\CudaTest2\hello.cu"
1>nvcc : fatal error : '-ccbin': expected a number
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 5.0.targets(592,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -G --keep-dir "x64\Debug" -maxrregcount=0 --machine 64 --compile -g -Xcompiler "/EHsc /W1 /nologo /O2 /Zi /MD " -o "x64\Debug\hello.cu.obj" "C:\Users\User\documents\visual studio 2010\Projects\CudaTest2\CudaTest2\hello.cu"" exited with code -1.
但是,使用 v100 平台工具集时出现此错误:
C:\Users\User\documents\visual studio 2010\Projects\CudaTest2\CudaTest2>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2010 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -G --keep-dir "x64\Debug" -maxrregcount=0 --machine 64 --compile -g -Xcompiler "/EHsc /W1 /nologo /O2 /Zi /MD " -o "x64\Debug\hello.cu.obj" "C:\Users\User\documents\visual studio 2010\Projects\CudaTest2\CudaTest2\hello.cu"
1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\math.h(455): error : dllexport/dllimport requires external linkage
1>C:/Users/User/documents/visual studio 2010/Projects/CudaTest2/CudaTest2/hello.cu(12): error : identifier "HANDLE_ERROR" is undefined
1>c:\program files\nvidia gpu computing toolkit\cuda\v5.0\include\math_functions.h(2900): error : function "hypotf" was referenced but not defined
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 5.0.targets(592,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2010 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -G --keep-dir "x64\Debug" -maxrregcount=0 --machine 64 --compile -g -Xcompiler "/EHsc /W1 /nologo /O2 /Zi /MD " -o "x64\Debug\hello.cu.obj" "C:\Users\User\documents\visual studio 2010\Projects\CudaTest2\CudaTest2\hello.cu"" exited with code 2.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
谁能指出我正确的方向?我已经阅读了几乎所有有关相关问题的帖子,安装和卸载了几次工具,但仍然无法获得正确的构建。