本来好好能运行的cuda程序,之后却变得不可编译了,求助。。。

oPuLinSiDun 2014-12-31 09:41:52
本来是已经在VS2010配置好的,测试程序都能运行,那时想运行个SDK的图像放大例子,例子里面有直接能打开PGM图像的现成函数,但因为里面没有cutil.h这个库,所以我自己导入了一个,能找到那个库了,但是编译不了。之后导致我的cuda程序也编译不了。。。。。。
#include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
//初始化CUDA
int count=0;
bool InitCUDA()
{
printf("Start to detecte devices.........\n");//显示检测到的设备数
cudaGetDeviceCount(&count);//检测计算能力大于等于1.0 的设备数
if(count == 0){
fprintf(stderr, "There is no device.\n");
return false;
}
printf("%d device/s detected.\n",count);//显示检测到的设备数
int i;
for(i = 0; i < count; i++){//依次验证检测到的设备是否支持CUDA
cudaDeviceProp prop;
if(cudaGetDeviceProperties(&prop, i) == cudaSuccess) {//获得设备属性并验证是否正确
if(prop.major >= 1)//验证主计算能力,即计算能力的第一位数是否大于1
{
printf("Device %d: %s supportsCUDA %d.%d.\n",i+1,prop.name,prop.major,prop.minor);//显示检测到的设备支持的CUDA 版本
break;
}
}
}
if(i == count) {//没有支持CUDA1.x 的设备
fprintf(stderr, "There is no device supporting CUDA 1.x.\n");
return false;
}
cudaSetDevice(i);//设置设备为主叫线程的当前设备
return true;
}
int main()
{
if(!InitCUDA()) {//初始化失败返回系统int argc, char** argv
return 0;
}
printf("Hello GPU! CUDA has been initialized.\n");
//exit(argc ? EXIT_SUCCESS : EXIT_FAILURE);
return 0;//返回系统
}
这里是程序,以下是错误信息:
1> F:\vs_sample\cuda\testGPU\testGPU>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2010 -ccbin "f:\vs2010\content\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\include" -G --keep-dir "Debug" -maxrregcount=0 --machine 32 --compile -g -Xcompiler "/EHsc /nologo /Od /Zi /MDd " -o "Debug\testgpu.cu.obj" "F:\vs_sample\cuda\testGPU\testGPU\testgpu.cu"
1> testgpu.cu
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\include\cuda_runtime.h(253): error : expected a ")"
1>
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\include\cuda_runtime.h(253): error : "T" is not a function or static data member
1>
1>f:\vs2010\content\VC\include\stdio.h(627): error : expression must be a pointer to a complete object type
1>
1>f:\vs2010\content\VC\include\stdio.h(629): error : expression must be a pointer to a complete object type
1>
1>f:\vs2010\content\VC\include\stdio.h(733): error : expected a declaration
1>
1>F:/vs_sample/cuda/testGPU/testGPU/testgpu.cu(5): warning : parsing restarts here after previous syntax error
1>
1>F:/vs_sample/cuda/testGPU/testGPU/testgpu.cu(9): error : identifier "count" is undefined
1>
1>F:/vs_sample/cuda/testGPU/testGPU/testgpu.cu(11): error : expression must be a pointer to a complete object type
1>
1>F:/vs_sample/cuda/testGPU/testGPU/testgpu.cu(27): error : expression must be a pointer to a complete object type
1>
1> 8 errors detected in the compilation of "C:/Users/ADMINI~1.WKR/AppData/Local/Temp/tmpxft_000006f8_00000000-3_testgpu.cpp1.ii".
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 4.2.targets(361,9): error MSB3721: 命令“"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2010 -ccbin "f:\vs2010\content\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\include" -G --keep-dir "Debug" -maxrregcount=0 --machine 32 --compile -g -Xcompiler "/EHsc /nologo /Od /Zi /MDd " -o "Debug\testgpu.cu.obj" "F:\vs_sample\cuda\testGPU\testGPU\testgpu.cu"”已退出,返回代码为 2。
1>
1>生成失败。
1>
1>已用时间 00:00:09.10
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
...全文
411 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

579

社区成员

发帖
与我相关
我的任务
社区描述
CUDA™是一种由NVIDIA推出的通用并行计算架构,该架构使GPU能够解决复杂的计算问题。 它包含了CUDA指令集架构(ISA)以及GPU内部的并行计算引擎。
社区管理员
  • CUDA编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧