compile error: "#" not expected here

2,508 views
Skip to first unread message

王建堯

unread,
Dec 4, 2015, 4:22:22 AM12/4/15
to MatConvNet: CNNs for MATLAB
excuse me.

I try to compile matconvnet-1.0-beta17 version and there are some unexpected "#" in cuda code which use cudnn.

Because currently I can not find cudnn v4.
Could the matconvnet works if I remove the part of code for checking cudnn version?

謝謝。

Andrea Vedaldi

unread,
Dec 9, 2015, 7:30:00 AM12/9/15
to MatConvNet: CNNs for MATLAB
Hi, I hope this is fixed in the just-released beta17 (the version you used was probably from the devel branch)

super...@gmail.com

unread,
Dec 9, 2015, 10:19:01 PM12/9/15
to MatConvNet: CNNs for MATLAB
Hi! I have encountered the same problem, too. Have you figured out how to fixed these errors yet ?

super...@gmail.com

unread,
Dec 9, 2015, 11:24:04 PM12/9/15
to MatConvNet: CNNs for MATLAB
Thanks a lot, I have fixed them by removing a few macros in "nnconv_cudnn.cu"

王建堯

unread,
Dec 11, 2015, 8:32:54 PM12/11/15
to MatConvNet: CNNs for MATLAB

cuDNN v4 Release Candidate Now Available


王建堯

unread,
Dec 11, 2015, 9:00:27 PM12/11/15
to MatConvNet: CNNs for MATLAB
i m not sure if the problem is only on windows or not.

but it can works if i choose the branch manually. :)

張家仁

unread,
Dec 15, 2015, 8:34:59 AM12/15/15
to MatConvNet: CNNs for MATLAB
My OS is Windows7 64-bit. My matlab version is R2014b, my CUDA version is 6.5 and uses visual studio 2013. 
And I still got this problem with the code in master branch and used cudnn v4.

How can I solve this problem?

王建堯於 2015年12月12日星期六 UTC+8上午10時00分27秒寫道:

Assaf Mushinsky

unread,
Dec 16, 2015, 5:13:12 PM12/16/15
to MatConvNet: CNNs for MATLAB
I had the same problem.

There is a problem with the CHECK(x) define in:

I have Win8, Matlab2015a, CUDA6.5, CUDNN 4rc, and visual studio 2013.

There is a #if condition to handle interface changes between CUDNN4 and older versions.
In order to do so, they use #if inside CHECK() which don't compile for some reason.

The way to fix it is to put the #if before CHECK (with some redundant code)

for example, instead of: (nnconv_cudnn.cu line 217)
        CHECK(cudnnAddTensor(handle,
#if (CUDNN_VERSION < 4000)
                             CUDNN_ADD_SAME_C,
#endif
                             &alpha,
                             biasesDesc, biases.getMemory() + biasesGrpOffset,
                             &beta,
                             outputDesc, output.getMemory() + outputGrpOffset)) ;

use:
#if (CUDNN_VERSION < 4000)
        CHECK(cudnnAddTensor(handle,
                             CUDNN_ADD_SAME_C,
                             &alpha,
                             biasesDesc, biases.getMemory() + biasesGrpOffset,
                             &beta,
                             outputDesc, output.getMemory() + outputGrpOffset)) ;
#else
        CHECK(cudnnAddTensor(handle,
                             &alpha,
                             biasesDesc, biases.getMemory() + biasesGrpOffset,
                             &beta,
                             outputDesc, output.getMemory() + outputGrpOffset)) ;

#endif

I also had to add #include <algorithm> for std::max().

I hope this helps.

Karel Lenc

unread,
Dec 29, 2015, 11:49:33 AM12/29/15
to MatConvNet: CNNs for MATLAB
Hi, thanks for reporting this problem and for the proposed solution!
It was really a bug just related to MSVC compiler when the CuDNN support was enabled...

I've created a new branch on Github called `win-cudnn-fix`, do you think you can test it? I don't have access to a Windows machine with a GPU, so I cannot test whether everything works.
I've also fixed few more bugs related to the MSVC 2010 so I hope I haven't broke anything on the way :)

Assaf Mushinsky

unread,
Dec 30, 2015, 3:34:31 PM12/30/15
to MatConvNet: CNNs for MATLAB
Hi Karel,
I've successfully compiled the 'win-cudnn-fix' branch using:
 - visual studio 2013
 - matlab 2015a
 - nvcc compiler
 - cuda 7.5
 - cudnn 4 rc

I had to make the following changes:
In \matconvnet-win-cudnn-fix\matlab\src\bits\impl\nnconv_cudnn.cu I had to add additional include:
#include <algorithm>

Why is the special branch required? 
I could easily compile the main branch using similar changes which can be protected using special flag for windows compilation.

Karel Lenc

unread,
Jan 5, 2016, 11:39:19 AM1/5/16
to MatConvNet: CNNs for MATLAB
Hi, the special branch was just temporary so I can check whether it does not break anything for other architectures. It seems to be fine, so I've merged it to master...
Also I've added the include <algorithm> which seems to be needed only for the MSVC2013...
I hope it will work now :)
Reply all
Reply to author
Forward
0 new messages