首先,要感谢zhang老师的指导,找出了问题所在
在网上发现有很多人都提出这个问题,这里说明一下问题的原因及解决方法
说一下配置库,
我是从http://download.csdn.net/detail/thesby/8411969#comment下载的
我的配置环境:
VS2012
cuda7.0;
在编译代码过程中,遇到如下错误信息:
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5762): error C2015: 常量中的字符太多
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5762): error C2146: 语法错误: 缺少“)”(在标识符“q”的前面)
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5762): error C2059: 语法错误:“)”
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5762): error C2001: 常量中有换行符
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5775): error C2143: 语法错误 : 缺少“)”(在“{”的前面)
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5775): error C2143: 语法错误 : 缺少“;”(在“{”的前面)
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5775): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5775): error C2015: 常量中的字符太多
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5783): error C2015: 常量中的字符太多
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5783): error C2059: 语法错误:“)”
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5783): error C2143: 语法错误 : 缺少“;”(在“}”的前面)
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5793): error C2015: 常量中的字符太多
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5793): error C2018: 未知字符“0x60”
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5793): error C2143: 语法错误 : 缺少“)”(在“常量”的前面)
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5793): error C2017: 非法的转义序列
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5793): error C2059: 语法错误:“)”
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5793): error C2001: 常量中有换行符
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5800): error C2143: 语法错误 : 缺少“)”(在“{”的前面)
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5800): error C2143: 语法错误 : 缺少“;”(在“{”的前面)
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5800): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5800): error C2015: 常量中的字符太多
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5811): error C2015: 常量中的字符太多
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5811): error C2059: 语法错误:“)”
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5811): error C2017: 非法的转义序列
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5811): error C2001: 常量中有换行符
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5817): error C2143: 语法错误 : 缺少“)”(在“{”的前面)
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5817): error C2143: 语法错误 : 缺少“;”(在“{”的前面)
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5817): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5817): error C2015: 常量中的字符太多
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5817): error C2017: 非法的转义序列
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5817): error C2001: 常量中有换行符
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5828): error C2015: 常量中的字符太多
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5828): error C2017: 非法的转义序列
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5838): error C2015: 常量中的字符太多
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5838): error C2017: 非法的转义序列
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5846): error C2015: 常量中的字符太多
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5846): error C2017: 非法的转义序列
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5846): error C2001: 常量中有换行符
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5854): error C2015: 常量中的字符太多
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5854): error C2001: 常量中有换行符
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5862): error C2015: 常量中的字符太多
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5868): error C2015: 常量中的字符太多
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\concrt.h(5868): error C2017: 非法的转义序列
1>tmpxft_00001664_00000000-2_bnll_layer.cudafe1.stub.c(4): fatal error C1004: 发现意外的文件尾
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations\CUDA 7.0.targets(593,9): error MSB3721: 命令“"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\bin\nvcc.exe" -gencode=arch=compute_30,code=\"sm_30,compute_30\" --use-local-env --cl-version 2012 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_amd64" -I../../3rdparty/include -I../../3rdparty/include/eigen3/Eigen -I../../src -I../../include -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\include" --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -g -D_VARIADIC_MAX=10 -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o Debug\bnll_layer.cu.obj "F:\Caffe demo0\src\caffe\layers\bnll_layer.cu"”已退出,返回代码为 2。
========== 全部重新生成: 成功 0 个,失败 1 个,跳过 0 个 ==========
第一个代码错误处,
extern "C" const __declspec(selectany) GUID SchedulerEventGuid = { 0xE2091F8A, 0x1E0A, 0x4731, { 0x84, 0xA2, 0x0D, 0xD5, 0x7C, 0x8A, 0x52, 0x61 } };
struct _GUID {
unsigned long Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[8];
} GUID;
可以发现,错误提示的文件是:
bnll_layer.cu
文件,编译发现,文件夹下所有的.cu编译都出现同样的错误
就此,我们在cuda下运行其自带的simple0项目,发现报出同样的错误,在其中任意一个.cu文件下右击属性,在cuda C++的命令行配置下添加如下命令
--verbose --keep
编译;
输出中间文件;在其对应的生成位置,我们发现如下代码:其编码方式是utf-8
extern "C" { __declspec(selectany) extern const GUID SchedulerEventGuid = {3792248714UL, ((unsigned short)7690U), ((unsigned short)18225U), {((unsigned char)'ħ), ((unsigned char)'§), ((unsigned char)'\r'), ((unsigned char)'է), ((unsigned char)'|'), ((unsigned char)'ʧ), ((unsigned char)'R'), ((unsigned char)'a')}}; }
结决方法其实很简单,使用cuda6.5即可;
我们在来看一下cuda6.5生成的中间文件:
extern "C" { __declspec(selectany) extern const GUID SchedulerEventGuid = {(3792248714U), (7690), (18225), {(132), (162), (13), (213), (124), (138), (82), (97)}}; }
因此,caffe在windows下cuda使用6.5和6.0版本的;
问题的到解决,编译通过