您的位置:首页 > Web前端

windows caffe gpu 配置

2017-08-30 16:37 369 查看
win7+vs2013+cuda7.5+cudnn4.0+NVIDIA GeForce GTX TITAN X

我的显卡是NVIDIA GeForce GTX TITAN X,计算能力5.2,支持cuda7.5

主要参考大神博客:

http://blog.csdn.net/zb1165048017/article/details/51549105

也可参考:

http://blog.csdn.net/u011185952/article/details/58596363

http://blog.csdn.net/u011185952/article/details/52577620

一步一步安装后出现的问题:

编译libcaffe出现:

1. 错误 1466 error C2146: 语法错误: 缺少“;”(在标识符“CAFFE_GET_BLOCKS”的前面) D:\caffe_gpu\caffe\src\caffe\layers\batch_reindex_layer.cu 30 1 caffe

2. 错误 1468 error C2059: 语法错误:“>” D:\caffe_gpu\caffe\src\caffe\layers\batch_reindex_layer.cu 30 1 caffe

3. 错误 1471 error C2146: 语法错误: 缺少“;”(在标识符“CAFFE_GET_BLOCKS”的前面) D:\caffe_gpu\caffe\src\caffe\layers\batch_reindex_layer.cu 97 1 caffe

4. 错误 1473 error C2059: 语法错误:“>” D:\caffe_gpu\caffe\src\caffe\layers\batch_reindex_layer.cu 97 1 caffe

5. 错误 1474 error MSB3721: 命令“”C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\bin\nvcc.exe” -gencode=arch=compute_20,code=\”sm_20,compute_20\” -gencode=arch=compute_30,code=\”sm_30,compute_30\” -gencode=arch=compute_35,code=\”sm_35,compute_35\” -gencode=arch=compute_50,code=\”sm_50,compute_50\” -gencode=arch=compute_52,code=\”sm_52,compute_52\” -gencode=arch=compute_20,code=\”sm_20,compute_20\” –use-local-env –cl-version 2013 -ccbin “D:\yanxiaopan\software_install\install_vs2013\VC\bin\x86_amd64” -I”C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\include” -I”C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\include” –keep-dir x64\Release -maxrregcount=0 –machine 64 –compile -cudart static -DUSE_LMDB -DUSE_OPENCV -DUSE_LEVELDB -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -DUNICODE -Xcompiler “/EHsc /W3 /nologo /O2 /Zi /MD ” -o x64\Release\batch_reindex_layer.cu.obj “D:\caffe_gpu\caffe\src\caffe\layers\batch_reindex_layer.cu””已退出,返回代码为 2。 C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations\CUDA 7.5.targets 604 9 caffe

出现问题后完全不知道为什么,搜MSB3721这个错误,都看了以下几个链接:

http://blog.csdn.net/hong__fang/article/details/52399900

http://blog.sina.com.cn/s/blog_78fd98af0101jl3r.html

https://stackoverflow.com/questions/20063982/error-msb3721-when-building-cuda-samples-for-vs2010-windows7-64bit

http://blog.csdn.net/a1340629895/article/details/46287023

https://stackoverflow.com/questions/12888247/cuda-error-msb3721-exited-with-code-2

http://blog.csdn.net/zhou894509/article/details/71079604

http://bbs.csdn.net/topics/392062086

发现有很多种情况都会报MSB3721的错误,试了上面各种方法都不行。

然后就想测试一下我的cuda7.5是不是安装正确了,测试后发现我的cuda7.5安的没有问题,又看到网上说安装cuda7.5时要选择自定义模式,全都安装,我第一次安装选的是精简模式,于是把cuda7.5卸载又重装,但是还是报同样的错误。

后来咨询别人说可能是cuda版本不对,于是我又下载了cuda8.0,卸载cuda7.5又安装了cuda8.0,还是同样的错误。

又想是不是因为源码的问题呢,于是按照以下链接重新配置,结果还是报上面的错误。

重新配置gpu 版caffe

1.

http://blog.csdn.net/chenqibob/article/details/52135614

2.

http://blog.csdn.net/changanlvren/article/details/52598202

3.

http://blog.csdn.net/u011511601/article/details/51205974

然后又想是不是cudnn版本的问题呢,又下载了cudnn-7.5-windows7-x64-v5.0-ga进行测试,依旧不行。感觉都要崩溃了!

后来运行cuda自带的例子simple Templates还是报类似的错误,凡是遇到<<<>>>运算符就会报错,就在网上搜类似错误,发现几种方法提到的解决方案都是在自己编写cuda程序中出现的,通过更改程序或选择编译器解决,可是我这个是源码呀,没办法更改。

后来又咨询了前辈,把我的问题阐述了一下,他说是不是因为vs2013没有安装在默认路径呀,他帮我找了好久没找到在哪更改vs2013的路径。于是,我又卸载了vs2013,因看网上说要先安装vs,然后再安装cuda,于是我把cuda8.0也卸载了。重装了vs2013和cuda8.0,都安装在默认路径,再重新编译libcaffe,果然没有上述问题了。

可是又出现新的问题:

1. “int” is not compatible with the parameter of type ”…..”

2. Identifier “…..” is undefined

3. too few arguments in function …….

在网上搜上述错误,有各种更改的方法,也有好多人说是cuda版本和cudnn版本不匹配,因为我当时是用的cuda8.0和cudnn-8.0-windows7-x64-v5.1,然后就想换一个cudnn,可是搜了好久找不到对应cuda8.0的cudnn5.0,好多人给链接去官网下载,可是官网打不开呀。

然后重新看大神的博客,说微软的caffe支持cudnn4.0和cudnn5.0,我用的是cudnn5.1呀,然后想到可能是我的caffe源码和cudnn的版本不匹配,于是,我并没有按照网上各种更改方法更改,而是果断又卸载了cuda8.0,安装了cuda7.5,并使用了cudnn-7.0-win-x64-v4.0-prod,最终编译成功!

配置gpu版caffe将近用了一周时间啊,头发掉了一大把。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: