>

2014년 12월 1일 월요일

caffe compile and install in Mac OSX 10.10.1, CUDA 6.5

** gflags 1.0  must be installed!
** glog 0.3.3 based on gflags 1.0.
** Make test gives run time error
[----------] 1 test from SolverTest/1, where TypeParam = caffe::DoubleCPU
[ RUN      ] SolverTest/1.TestInitTrainTestNets
test_all.testbin(95309,0x7fff7d0e2300) malloc: *** error for object 0x110afa7a0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

make: *** [runtest] Abort trap: 6

--------------------
mybuild $ cmake ..
-- Found leveldb in /usr/local/include /usr/local/lib/libleveldb.dylib
-- Found Snappy: /usr/local/lib/libsnappy.dylib  
-- LMDB lib: /usr/local/lib/liblmdb.dylib
-- LMDB include: 
-- Found LMDB: /usr/local/include  
-- Boost version: 1.56.0
-- Found the following Boost libraries:
--   system
--   thread
-- Found PROTOBUF: /usr/local/lib/libprotobuf.dylib  
-- Found PROTOBUF Compiler: /usr/local/bin/protoc
-- Examples enabled
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/yndk/Downloads/caffe-master/mybuild

mybuild $ make all
Scanning dependencies of target gtest
[  1%] Building CXX object src/gtest/CMakeFiles/gtest.dir/gtest-all.cpp.o
In file included from /Users/yndk/Downloads/caffe-master/src/gtest/gtest-all.cpp:39:
/Users/yndk/Downloads/caffe-master/src/gtest/gtest.h:1561:13: fatal error: 'tr1/tuple' file not
      found
#   include <tr1/tuple>  // NOLINT
            ^
1 error generated.
--------------------------
So, I modified the line 28 of CMakeList.txt file as follows

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -stdlib=libstdc++") # set global flags
--------------------------
mybuild $ make all
...
caffe-master/include/caffe/util/mkl_alternate.hpp:11:10: fatal error: 
      'cblas.h' file not found
#include <cblas.h>
         ^

1 error generated.
--------------------------
So, I modified the line 28 of CMakeList.txt file as follows

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -stdlib=libstdc++ -I/System/Library/Frameworks/Accelerate.framework/Versions/C    urrent/Frameworks/vecLib.framework/Versions/Current/Headers -framework Accelerate") # set global flags
--------------------------
mybuild $ make
-- Found leveldb in /usr/local/include /usr/local/lib/libleveldb.dylib
-- LMDB lib: /usr/local/lib/liblmdb.dylib
-- LMDB include: 
-- Boost version: 1.56.0
-- Found the following Boost libraries:
--   system
--   thread
-- Found PROTOBUF Compiler: /usr/local/bin/protoc
-- Examples enabled
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/yndk/Downloads/caffe-master/mybuild
[  1%] Built target gtest
[  1%] Built target gtest_main
[  4%] Built target proto
[  5%] Building NVCC (Device) object src/caffe/CMakeFiles/caffe_cu.dir/util/./caffe_cu_generated_math_functions.cu.o
clang: warning: -framework Accelerate: 'linker' input unused
clang: warning: -framework Accelerate: 'linker' input unused
clang: warning: -framework Accelerate: 'linker' input unused
clang: warning: -framework Accelerate: 'linker' input unused
clang: warning: -framework Accelerate: 'linker' input unused
/usr/local/include/boost/config/suffix.hpp(496): error: identifier "__int128" is undefined

/usr/local/include/boost/config/suffix.hpp(497): error: expected a ";"

2 errors detected in the compilation of "/var/folders/cn/yf6gmhss2g96zb6933m4v0t00000gn/T//tmpxft_00012ea7_00000000-12_math_functions.compute_35.cpp1.ii".
CMake Error at caffe_cu_generated_math_functions.cu.o.cmake:264 (message):
  Error generating file
  /Users/yndk/Downloads/caffe-master/mybuild/src/caffe/CMakeFiles/caffe_cu.dir/util/./caffe_cu_generated_math_functions.cu.o


make[2]: *** [src/caffe/CMakeFiles/caffe_cu.dir/util/./caffe_cu_generated_math_functions.cu.o] Error 1
make[1]: *** [src/caffe/CMakeFiles/caffe_cu.dir/all] Error 2
make: *** [all] Error 2

------------------------------------
So, I added the following to /usr/local/include/boost/config/compiler/nvcc.hpp
// yndk
#ifdef BOOST_HAS_INT128
#undef BOOST_HAS_INT128
#endif
------------------------------------

mybuild $ make
-- Found leveldb in /usr/local/include /usr/local/lib/libleveldb.dylib
-- LMDB lib: /usr/local/lib/liblmdb.dylib
-- LMDB include: 
-- Boost version: 1.56.0
-- Found the following Boost libraries:
--   system
--   thread
-- Found PROTOBUF Compiler: /usr/local/bin/protoc
-- Examples enabled
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/yndk/Downloads/caffe-master/mybuild
[  1%] Built target gtest
[  1%] Built target gtest_main
[  4%] Built target proto
[  5%] Building NVCC (Device) object src/caffe/CMakeFiles/caffe_cu.dir/util/./caffe_cu_generated_math_functions.cu.o
clang: warning: -framework Accelerate: 'linker' input unused
clang: warning: -framework Accelerate: 'linker' input unused
clang: warning: -framework Accelerate: 'linker' input unused
clang: warning: -framework Accelerate: 'linker' input unused
clang: warning: -framework Accelerate: 'linker' input unused
/usr/local/include/boost/config/suffix.hpp(496): error: identifier "__int128" is undefined

/usr/local/include/boost/config/suffix.hpp(497): error: expected a ";"

2 errors detected in the compilation of "/var/folders/cn/yf6gmhss2g96zb6933m4v0t00000gn/T//tmpxft_00012ea7_00000000-12_math_functions.compute_35.cpp1.ii".
CMake Error at caffe_cu_generated_math_functions.cu.o.cmake:264 (message):
  Error generating file
  /Users/yndk/Downloads/caffe-master/mybuild/src/caffe/CMakeFiles/caffe_cu.dir/util/./caffe_cu_generated_math_functions.cu.o


make[2]: *** [src/caffe/CMakeFiles/caffe_cu.dir/util/./caffe_cu_generated_math_functions.cu.o] Error 1
make[1]: *** [src/caffe/CMakeFiles/caffe_cu.dir/all] Error 2
make: *** [all] Error 2

------------------------
So, another file. I placed at the beginning of the file: /usr/local/include/boost/config/suffix.hpp
//yndk
#if defined(BOOST_HAS_INT128)
#undef BOOST_HAS_INT128
#endif
//yndk
------------------------
mybuild $ make
[  1%] Built target gtest
[  1%] Built target gtest_main
[  4%] Built target proto
[  5%] Building NVCC (Device) object src/caffe/CMakeFiles/caffe_cu.dir/util/./caffe_cu_generated_math_functions.cu.o
...
[ 85%] Built target caffe
Scanning dependencies of target caffe.bin
[ 87%] Building CXX object tools/CMakeFiles/caffe.bin.dir/caffe.cpp.o
clang: warning: -framework Accelerate: 'linker' input unused
Linking CXX executable caffe
Undefined symbols for architecture x86_64:
  "cv::imread(std::string const&, int)", referenced from:
      caffe::ReadImageToDatum(std::string const&, int, int, int, bool, caffe::Datum*) in libcaffe.a(io.cpp.o)
      caffe::WindowDataLayer<float>::InternalThreadEntry() in libcaffe.a(window_data_layer.cpp.o)
      caffe::WindowDataLayer<double>::InternalThreadEntry() in libcaffe.a(window_data_layer.cpp.o)
  "google::SetUsageMessage(std::string const&)", referenced from:
      _main in caffe.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [tools/caffe] Error 1
make[1]: *** [tools/CMakeFiles/caffe.bin.dir/all] Error 2
make: *** [all] Error 2
-------------------------------
Now, I need an appropriate opencv for caffe.
opencv-3.0.0-beta with CUDA is installed.
----
caffe-master $ make
/usr/bin/clang++ src/caffe/layers/window_data_layer.cpp -stdlib=libstdc++ -framework Accelerate -pthread -fPIC -DNDEBUG -O2 -I/usr/local/include -I.build_release/src -I./src -I./include -I/usr/local/cuda/include -I/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Versions/Current/Headers -Wall -Wno-sign-compare -Wno-unneeded-internal-declaration -c -o .build_release/src/caffe/layers/window_data_layer.o 2> .build_release/src/caffe/layers/window_data_layer.o.warnings.txt \
|| (cat .build_release/src/caffe/layers/window_data_layer.o.warnings.txt; exit 1)
clang: warning: -framework Accelerate: 'linker' input unused
src/caffe/layers/window_data_layer.cpp:230:48: error: use of undeclared identifier 'CV_LOAD_IMAGE_COLOR'
      cv::Mat cv_img = cv::imread(image.first, CV_LOAD_IMAGE_COLOR);
                                               ^
1 error generated.

make: *** [.build_release/src/caffe/layers/window_data_layer.o] Error 1
---------
line 230 is replaced as follows
      //cv::Mat cv_img = cv::imread(image.first, CV_LOAD_IMAGE_COLOR);
      cv::Mat cv_img = cv::imread(image.first, cv::IMREAD_COLOR);
--------

댓글 없음:

댓글 쓰기