caffe2 icon indicating copy to clipboard operation
caffe2 copied to clipboard

caffe2 compiled error on MAC!

Open changkaizhao opened this issue 9 years ago • 7 comments

I followed the order as below:

brew install openblas glog gtest automake protobuf leveled lmdb
mkdir build && cd build
cmake .. -DBLAS=OpenBLAS -DUSE_OPENCV=on
make

it generates errors :

[ 26%] Building CXX object caffe2/CMakeFiles/Caffe2_CPU.dir/operators/conv_gradient_op.cc.o
[ 26%] Building CXX object caffe2/CMakeFiles/Caffe2_CPU.dir/operators/conv_op.cc.o
[ 27%] Building CXX object caffe2/CMakeFiles/Caffe2_CPU.dir/operators/conv_op_eigen.cc.o
In file included from 
/Project/caffe2/caffe2/operators/conv_op_eigen.cc:5:
In file included from 
/Project/caffe2/third_party/eigen/unsupported/Eigen/CXX11/Tensor:30:
In file included from /Project/caffe2/third_party/eigen/unsupported/Eigen/CXX11/../SpecialFunctions:46:
/Project/caffe2/third_party/eigen/unsupported/Eigen/CXX11/../src/SpecialFunctions/SpecialFunctionsImpl.h:82:3: error: 
      unknown type name 'EIGEN_DEVICE_FUNC'
  EIGEN_DEVICE_FUNC
  ^
/Project/caffe2/third_party/eigen/unsupported/Eigen/CXX11/../src/SpecialFunctions/SpecialFunctionsImpl.h:83:3: error: 
      expected member name or ';' after declaration specifiers
  static EIGEN_STRONG_INLINE Scalar run(const Scalar x, const Scalar coef[]) {
  ^
/Project/caffe2/third_party/eigen/unsupported/Eigen/CXX11/../src/SpecialFunctions/SpecialFunctionsImpl.h:92:3: error: 
      unknown type name 'EIGEN_DEVICE_FUNC'
  EIGEN_DEVICE_FUNC
  ^
/Project/caffe2/third_party/eigen/unsupported/Eigen/CXX11/../src/SpecialFunctions/SpecialFunctionsImpl.h:93:3: error: 
      expected member name or ';' after declaration specifiers
  static EIGEN_STRONG_INLINE Scalar run(const Scalar, const Scalar coef[]) {
  ^
/Project/caffe2/third_party/eigen/unsupported/Eigen/CXX11/../src/SpecialFunctions/SpecialFunctionsImpl.h:106:3: error: 
      unknown type name 'EIGEN_DEVICE_FUNC'
  EIGEN_DEVICE_FUNC
  ^
/Project/caffe2/third_party/eigen/unsupported/Eigen/CXX11/../src/SpecialFunctions/SpecialFunctionsImpl.h:107:3: error: 
      expected member name or ';' after declaration specifiers
  static EIGEN_STRONG_INLINE Scalar run(const Scalar) {
  ^
/Project/caffe2/third_party/eigen/unsupported/Eigen/CXX11/../src/SpecialFunctions/SpecialFunctionsImpl.h:171:3: error: 
      unknown type name 'EIGEN_DEVICE_FUNC'
  EIGEN_DEVICE_FUNC
  ^
/Project/caffe2/third_party/eigen/unsupported/Eigen/CXX11/../src/SpecialFunctions/SpecialFunctionsImpl.h:172:3: error: 
      expected member name or ';' after declaration specifiers
  static EIGEN_STRONG_INLINE Scalar run(const Scalar) {
  ^
/Project/caffe2/third_party/eigen/unsupported/Eigen/CXX11/../src/SpecialFunctions/SpecialFunctionsImpl.h:182:3: error: 
      unknown type name 'EIGEN_DEVICE_FUNC'
  EIGEN_DEVICE_FUNC
  ^
/Project/caffe2/third_party/eigen/unsupported/Eigen/CXX11/../src/SpecialFunctions/SpecialFunctionsImpl.h:183:3: error: 
      expected member name or ';' after declaration specifiers
  static EIGEN_STRONG_INLINE float run(const float s) {
  ^
/Project/caffe2/third_party/eigen/unsupported/Eigen/CXX11/../src/SpecialFunctions/SpecialFunctionsImpl.h:201:3: error: 
      unknown type name 'EIGEN_DEVICE_FUNC'
  EIGEN_DEVICE_FUNC
  ^
/Project/caffe2/third_party/eigen/unsupported/Eigen/CXX11/../src/SpecialFunctions/SpecialFunctionsImpl.h:202:3: error: 
      expected member name or ';' after declaration specifiers
  static EIGEN_STRONG_INLINE double run(const double s) {
  ^
/Project/caffe2/third_party/eigen/unsupported/Eigen/CXX11/../src/SpecialFunctions/SpecialFunctionsImpl.h:224:3: error: 
      unknown type name 'EIGEN_DEVICE_FUNC'
  EIGEN_DEVICE_FUNC
  ^
/Project/caffe2/third_party/eigen/unsupported/Eigen/CXX11/../src/SpecialFunctions/SpecialFunctionsImpl.h:225:3: error: 
      expected member name or ';' after declaration specifiers
  static Scalar run(Scalar x) {
  ^
/Project/caffe2/third_party/eigen/unsupported/Eigen/CXX11/../src/SpecialFunctions/SpecialFunctionsImpl.h:340:3: error: 
      unknown type name 'EIGEN_DEVICE_FUNC'
  EIGEN_DEVICE_FUNC
  ^
/Project/caffe2/third_party/eigen/unsupported/Eigen/CXX11/../src/SpecialFunctions/SpecialFunctionsImpl.h:341:3: error: 
      expected member name or ';' after declaration specifiers
  static EIGEN_STRONG_INLINE Scalar run(const Scalar) {
  ^
/Project/caffe2/third_party/eigen/unsupported/Eigen/CXX11/../src/SpecialFunctions/SpecialFunctionsImpl.h:373:3: error: 
      unknown type name 'EIGEN_DEVICE_FUNC'
  EIGEN_DEVICE_FUNC
  ^
/Project/caffe2/third_party/eigen/unsupported/Eigen/CXX11/../src/SpecialFunctions/SpecialFunctionsImpl.h:374:3: error: 
      expected member name or ';' after declaration specifiers
  static EIGEN_STRONG_INLINE Scalar run(const Scalar) {
  ^
/Project/caffe2/third_party/eigen/unsupported/Eigen/CXX11/../src/SpecialFunctions/SpecialFunctionsImpl.h:412:3: error: 
      unknown type name 'EIGEN_DEVICE_FUNC'
  EIGEN_DEVICE_FUNC
  ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [caffe2/CMakeFiles/Caffe2_CPU.dir/operators/conv_op_eigen.cc.o] Error 1
make[1]: *** [caffe2/CMakeFiles/Caffe2_CPU.dir/all] Error 2
make: *** [all] Error 2

changkaizhao avatar Apr 21 '17 13:04 changkaizhao

@changkaizhao seems like your eigen is not installed properly. Would you mind check you eigen version. Would you mind try brew install eigen or build eigen from source?

harouwu avatar Apr 21 '17 21:04 harouwu

@harouwu it works!

changkaizhao avatar Apr 22 '17 12:04 changkaizhao

but it appear other errors as below:

[ 56%] Linking CXX shared library libCaffe2_CPU.dylib
[ 56%] Built target Caffe2_CPU
[ 56%] Building NVCC (Device) object caffe2/CMakeFiles/Caffe2_GPU.dir/utils/Caffe2_GPU_generated_math_gpu.cu.o
In file included from <built-in>:339:
In file included from <command line>:19:
In file included from /usr/local/cuda/include/cuda_runtime.h:112:
/usr/local/cuda/include/common_functions.h:65:10: fatal error: 'string.h' file not found
#include <string.h>
         ^
1 error generated.
CMake Error at Caffe2_GPU_generated_math_gpu.cu.o.cmake:203 (message):
  Error generating
  /Project/caffe2/build/caffe2/CMakeFiles/Caffe2_GPU.dir/utils/./Caffe2_GPU_generated_math_gpu.cu.o


make[2]: *** [caffe2/CMakeFiles/Caffe2_GPU.dir/utils/Caffe2_GPU_generated_math_gpu.cu.o] Error 1
make[1]: *** [caffe2/CMakeFiles/Caffe2_GPU.dir/all] Error 2
make: *** [all] Error 2

changkaizhao avatar Apr 22 '17 12:04 changkaizhao

@changkaizhao Please try xcode-select --install . Seems like this problem is related to Mac's clang

harouwu avatar Apr 23 '17 19:04 harouwu

You may want to try installing without CUDA on your Mac. Try this (add the opencv and blas stuff if you need it):

cmake -DUSE_CUDA=OFF ..
sudo make install

There are some issues with CUDA 8 and the latest version of Clang forcing some folks to downgrade their xcode CLTs, so you can try that as well.

aaronmarkham avatar Apr 24 '17 21:04 aaronmarkham

@aaronmarkham yes, I found the latest cuda8.0.61 support xcode8.2 on MacOS 10.12. I install Xcode8.2 alongside Xcode 8.3(i need to compile ios10.3 app) to fix this problem. thanks your reply!

changkaizhao avatar Apr 25 '17 03:04 changkaizhao

Same problem under Ubuntu 14.04, I have installed libeigen2-dev and libeigen3-dev but I got same error message concerning Eigen...

H4E avatar May 02 '17 22:05 H4E