代码改变世界

cudnn.hpp中 cudnnGetErrorString与cudnn.h不兼容问题

2015-10-23 23:59  Erdos001  阅读(2557)  评论(0编辑  收藏  举报

Thanks for the great tutorial!
I have been using Caffe on linux for a while now, but since I’m new to linux I was always struggling to get things working.
This makes life a lot easier!
I compiled it on windows 7, VS2013, CUDA7.0

Everything works, including my own previous “linux caffe” experiments.
Only problem: it’s quite a lot slower, in the order of 3 times slower.
This is probably due to CUDNN, which I couldn’t get to work.

I have used the latest master branch by BVLC (08 juli 2015) and tried the following things to get CUDNN working:

first attempt with latest CUDNN (cudnn-6.5-win-v2-rc3)
– Add path to CUDNN folder to “additional include dirs”
– Add path to CUDNN folder to “additional library dirs”
– Add cudnn.lib, cudnn64_65.lib to “additional dependencies”
– add “USE_CUDNN” to the preprocessor definitions
– set CUDA C/C++ -> common-> target machine type” to “64 bit”

If I now try to compile any of the cudnn layers, for instance: cudnn_conv_layer.c, I get the following errors:

IntelliSense: declaration is incompatible with “const char *__stdcall cudnnGetErrorString(cudnnStatus_t status)” (declared at line 98 of “D:\toolkits\cudnn_v2\cudnn.h”) d:\caffe\caffe-master\include\caffe\util\cudnn.hpp 17 20 caffe
Error

error MSB3721: The command “”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 2013 -ccbin “C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64″ -I../3rdparty/include -I../3rdparty/include/openblas -I../3rdparty/include/hdf5 -I../3rdparty/include/lmdb -I../include -I../src -ID:\toolkits\boost_1_56_0 -I”D:\toolkits\opencv-2.4.9\build\include” -I”D:\toolkits\opencv-2.4.9\build\include\opencv” -I”C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\include” -ID:\toolkits\cudnn_v2 -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\Release -maxrregcount=0 –machine 64 –compile -cudart static -DWIN32 -DNDEBUG -D_CONSOLE -D_LIB -D_CRT_SECURE_NO_WARNINGS -DUSE_CUDNN -D_UNICODE -DUNICODE -Xcompiler “/EHsc /W3 /nologo /O2 /Zi /MD ” -o x64\Release\cudnn_conv_layer.cu.obj“D:\caffe\caffe-master\src\caffe\layers\cudnn_conv_layer.cu”” exited with code 2.

error : declaration is incompatible with “const char *cudnnGetErrorString(cudnnStatus_t)” D:\caffe\caffe-master\include\caffe\util\cudnn.hpp 17 1 caffe

It seems that there are some incompatibilities between CUDNN V2 and caffe CUDNN layers.
If I instead use CUDNN V1 I get some other errors:

IntelliSense: expected a ‘;’ d:\caffe\caffe-master\include\caffe\util\cudnn.hpp 127 1

error MSB3721: The command “”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 2013 -ccbin “C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64″ -I../3rdparty/include -I../3rdparty/include/openblas -I../3rdparty/include/hdf5 -I../3rdparty/include/lmdb -I../include -I../src -ID:\toolkits\boost_1_56_0 -I”D:\toolkits\opencv-2.4.9\build\include” -I”D:\toolkits\opencv-2.4.9\build\include\opencv” -I”C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\include” -ID:\toolkits\cudnn_v1 -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\Release -maxrregcount=0 –machine 64 –compile -cudart static -DWIN32 -DNDEBUG -D_CONSOLE -D_LIB -D_CRT_SECURE_NO_WARNINGS -DUSE_CUDNN -D_UNICODE -DUNICODE -Xcompiler “/EHsc /W3 /nologo /O2 /Zi /MD ” -o x64\Release\conv_layer.cu.obj“D:\caffe\caffe-master\src\caffe\layers\conv_layer.cu”” exited with code 2.

error : identifier “cudnnTensorDescriptor_t” is undefined D:\caffe\caffe-master\include\caffe\util\cudnn.hpp 64 1 caffe
error : identifier “cudnnTensorDescriptor_t” is undefined D:\caffe\caffe-master\include\caffe\util\cudnn.hpp 69 1 caffe
error : identifier “cudnnTensorDescriptor_t” is undefined D:\caffe\caffe-master\include\caffe\util\cudnn.hpp 77 1 caffe
error : identifier “cudnnTensorDescriptor_t” is undefined D:\caffe\caffe-master\include\caffe\util\cudnn.hpp 102 1 caffe

It now seems that “cudnnTensorDescriptor_t” can not be found at all, as opposed to an incompatible declaration.
Now ofcourse the question, what am I doing wrong? Did I forget something, or should I use a different version of CUDNN (any of the Release candidates maybe?)

I would be really gratefull if you, or anyone else, could help me out :)

    1. Freerk Venhuizen 

      Solved it!
      Using CUDNN v2, I had to change the following in cudnn.hpp

      “inline const char* cudnnGetErrorString(cudnnStatus_t status)”
      to
      “inline const char * CUDNNWINAPI cudnnGetErrorString(cudnnStatus_t status)”

      Now it works great with a speedup of 3x, similiar to linux performance