Caffe: cuda_fp16.hpp:103:16: error: expected unqualified-id before numeric constant

Created on 25 Oct 2017  Â·  5Comments  Â·  Source: BVLC/caffe

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

Most helpful comment

I encountered the same problem. May I know if you have found a way to fix it? Thank you!

All 5 comments

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;

  1. in cmakelists, SET(CUDA_NVCC_FLAGS --compiler-options "-std=c++03";-arch=sm_30)
  2. in cmakelists, set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
Was this page helpful?
0 / 5 - 0 ratings

Related issues

LarsHH picture LarsHH  Â·  3Comments

weather319 picture weather319  Â·  3Comments

kelvinxu picture kelvinxu  Â·  3Comments

FreakTheMighty picture FreakTheMighty  Â·  3Comments

prathmeshrmadhu picture prathmeshrmadhu  Â·  3Comments