Ubuntu:17.10
GCC:4.7.4
CUDA:9.0
when i make matcaffe with add CXXFLAGS += -std=c++11 in Makefile , i get:
MEX matlab/+caffe/private/caffe_.cpp
Building with 'g++'.
In file included from /usr/local/cuda/include/cuda_fp16.h:1967:0,
from /usr/local/cuda/include/cublas_api.h:75,
from /usr/local/cuda/include/cublas_v2.h:65,
from ./include/caffe/util/device_alternate.hpp:34,
from ./include/caffe/common.hpp:19,
from ./include/caffe/blob.hpp:8,
from ./include/caffe/caffe.hpp:7,
from /home/zhang/caffe-master/matlab/+caffe/private/caffe_.cpp:18:
/usr/local/cuda/include/cuda_fp16.hpp:103:16: error: expected unqualified-id before numeric constant
/usr/local/cuda/include/cuda_fp16.hpp:103:16: error: expected ‘)’ before numeric constant
/usr/local/cuda/include/cuda_fp16.hpp:105:3: error: ‘__half_raw’ does not name a type
/usr/local/cuda/include/cuda_fp16.hpp:107:16: error: expected unqualified-id before numeric constant
/usr/local/cuda/include/cuda_fp16.hpp:107:16: error: expected ‘)’ before numeric constant
/usr/local/cuda/include/cuda_fp16.hpp:109:3: error: ‘__half2_raw’ does not name a type
/usr/local/cuda/include/cuda_fp16.hpp:123:8: error: expected unqualified-id before numeric constant
/usr/local/cuda/include/cuda_fp16.hpp:123:8: error: expected ‘)’ before numeric constant
In file included from /usr/local/cuda/include/cuda_fp16.h:1967:0,
from /usr/local/cuda/include/cublas_api.h:75,
from /usr/local/cuda/include/cublas_v2.h:65,
from ./include/caffe/util/device_alternate.hpp:34,
from ./include/caffe/common.hpp:19,
from ./include/caffe/blob.hpp:8,
from ./include/caffe/caffe.hpp:7,
from /home/zhang/caffe-master/matlab/+caffe/private/caffe_.cpp:18:
/usr/local/cuda/include/cuda_fp16.hpp:248:27: error: expected declaration before end of line
I encountered the same problem. May I know if you have found a way to fix it? Thank you!
I got the same problem too.
Looks like g++ 4.7 does not handle C++11 well. I can compile with no problems using version 4.8.4, but compiling with 4.7 fails exactly the same way as in your case. I suggest installing g++-4.8 and selecting it in Makefile.config (CUSTOM_CXX :=g++-4.8) then compiling again.
I got a solution but it is not very elegant.
find the location of the file cublas_v2.h, and update the environment variables in ~/.bashrc file with (for me)
export CPLUS_INCLUDE_PATH=/usr/local/cuda-8.0/targets/x86_64-linux/include:$CPLUS_INCLUDE_PATH
i handle this:
1.use g++-4.8;
2.export CPLUS_INCLUDE_PATH=/usr/local/cuda/include/:$CPLUS_INCLUDE_PATH;
Most helpful comment
I encountered the same problem. May I know if you have found a way to fix it? Thank you!