Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac 10.12.1 Sierra Xcode 8.1 cmake error (1).not Found vecLib (2).ImportError: No module named numpy (3).Undefined symbols for architecture x86_64 cv::imread(std::__1::basic_string (4) make runtest. Aborted at (unix time) using GNU date #4926

Closed
Phynixknight opened this issue Oct 30, 2016 · 11 comments

Comments

@Phynixknight
Copy link

Phynixknight commented Oct 30, 2016

I find there is no 10.12 in the makefile
in makefile there is:
\# 10.10 has accelerate while 10.9 has veclib XCODE_CLT_VER := $(shell pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep 'version' | sed 's/[^0-9]*\([0-9]\).*/\1/') XCODE_CLT_GEQ_7 := $(shell [ $(XCODE_CLT_VER) -gt 6 ] && echo 1) XCODE_CLT_GEQ_6 := $(shell [ $(XCODE_CLT_VER) -gt 5 ] && echo 1)
when I execute
pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
it shows:
No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.

when I find / -name 'vecLib.h'
it shows:
AppleTV SDK balabala... Swift SDK balabala... /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/Headers/vecLib.h /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/vecLib/vecLib.h
which one should I use.

The best way is to modify Makefile or CmakeCache file?

@Phynixknight Phynixknight changed the title Mac 10.12.1 Sierra cmake error Couldn't find vecLib Mac 10.12.1 Sierra Xcode 8.0 cmake error Couldn't find vecLib Oct 30, 2016
@Phynixknight
Copy link
Author

Phynixknight commented Nov 1, 2016

I have update my xcode to 8.1 and this problem also has been solved.
But a new problem has happened.

-- Boost version: 1.60.0
-- Found the following Boost libraries:
--   system
--   thread
--   filesystem
-- Found gflags  (include: /usr/local/include, library: /usr/local/lib/libgflags.dylib)
-- Found glog    (include: /usr/local/include, library: /usr/local/lib/libglog.dylib)
-- Found PROTOBUF Compiler: /usr/local/bin/protoc
-- Found lmdb    (include: /usr/local/include, library: /usr/local/lib/liblmdb.dylib)
-- Found LevelDB (include: /usr/local/include, library: /usr/local/lib/libleveldb.dylib)
-- Found Snappy  (include: /Users/phynix/anaconda/include, library: /Users/phynix/anaconda/lib/libsnappy.dylib)
-- CUDA detected: 8.0
-- Found cuDNN: ver. 5.1.5 found (include: /usr/local/cuda/include, library: /usr/local/cuda/lib/libcudnn.dylib)
-- Automatic GPU detection failed. Building for all known architectures.
-- Added CUDA NVCC flags for: sm_20 sm_21 sm_30 sm_35 sm_50
-- OpenCV found (/Users/phynix/anaconda/share/OpenCV)
-- Found standalone vecLib.framework
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named numpy
-- Could NOT find NumPy (missing:  NUMPY_INCLUDE_DIR NUMPY_VERSION) (Required is at least version "1.7.1")
-- Boost version: 1.60.0
-- Found the following Boost libraries:
--   python
-- Found Doxygen: /usr/local/bin/doxygen (found version "1.8.12")
-- Python interface is disabled or not all required dependencies found. Building without it...
-- Detected Doxygen OUTPUT_DIRECTORY: ./doxygen/
--
-- ******************* Caffe Configuration Summary *******************
-- General:
--   Version           :   1.0.0-rc3
--   Git               :   rc3-272-g6491504-dirty
--   System            :   Darwin
--   C++ compiler      :   /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
--   Release CXX flags :   -O3 -DNDEBUG -fPIC -Wall -Wno-sign-compare -Wno-uninitialized
--   Debug CXX flags   :   -g -fPIC -Wall -Wno-sign-compare -Wno-uninitialized
--   Build type        :   Release
--
--   BUILD_SHARED_LIBS :   ON
--   BUILD_python      :   ON
--   BUILD_matlab      :   OFF
--   BUILD_docs        :   ON
--   CPU_ONLY          :   OFF
--   USE_OPENCV        :   ON
--   USE_LEVELDB       :   ON
--   USE_LMDB          :   ON
--   ALLOW_LMDB_NOLOCK :   OFF
--
-- Dependencies:
--   BLAS              :   Yes (vecLib)
--   Boost             :   Yes (ver. 1.60)
--   glog              :   Yes
--   gflags            :   Yes
--   protobuf          :   Yes (ver. 3.1.0)


--   lmdb              :   Yes (ver. 0.9.18)
--   LevelDB           :   Yes (ver. 1.19)
--   Snappy            :   Yes (ver. 1.1.3)
--   OpenCV            :   Yes (ver. 2.4.11)
--   CUDA              :   Yes (ver. 8.0)
--
-- NVIDIA CUDA:
--   Target GPU(s)     :   Auto
--   GPU arch(s)       :   sm_20 sm_21 sm_30 sm_35 sm_50
--   cuDNN             :   Yes (ver. 5.1.5)
--
-- Documentaion:
--   Doxygen           :   /usr/local/bin/doxygen (1.8.12)
--   config_file       :   /Users/phynix/Software/Caffe/caffe/.Doxyfile
--
-- Install:
--   Install path      :   /Users/phynix/Software/Caffe/caffe/cmake_build/install
--
-- Configuring done
CMake Error at CMakeLists.txt:85 (add_dependencies):
  The dependency target "pycaffe" of target "pytest" does not exist.


-- Generating done
-- Build files have been written to: /Users/phynix/Software/Caffe/caffe/cmake_build
FAIL

I installed the python, opencv and numpy via anaconda, and I can import numpy in python.

cmake                     3.3.1                         0
numpy                     1.11.2                   py27_0   
python                    2.7.12                        1   
boost                     1.60.0                   py27_0   
boost-python              1.55.0                        0    ericdill   
opencv                    2.4.11                   py27_1    https://conda.binstar.org/menpo   

@Phynixknight Phynixknight changed the title Mac 10.12.1 Sierra Xcode 8.0 cmake error Couldn't find vecLib Mac 10.12.1 Sierra Xcode 8.1 cmake.. FAIL Could NOT find NumPy Nov 1, 2016
@Phynixknight
Copy link
Author

finally, I found the failure reason.
When I use which -a python,it shows

/usr/bin/python

But I modified the FindNumpy.cmake, adding

  execute_process(COMMAND "which" "${PYTHON_EXECUTABLE}")
  execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-V")

It shows/opt/local/bin/python, what's wrong?

So I echo $PATH, I find /opt/local/bin was added by MacPorts manually, like this

# MacPorts Installer addition on 2016-08-14_at_07:59:03: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"

wtf...

@Phynixknight
Copy link
Author

Phynixknight commented Nov 9, 2016

Record

-- The C compiler identification is AppleClang 8.0.0.8000042
-- The CXX compiler identification is AppleClang 8.0.0.8000042
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Boost version: 1.60.0
-- Found the following Boost libraries:
--   system
--   thread
--   filesystem
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Found GFlags: /usr/local/include
-- Found gflags  (include: /usr/local/include, library: /usr/local/lib/libgflags.dylib)
-- Found Glog: /usr/local/include
-- Found glog    (include: /usr/local/include, library: /usr/local/lib/libglog.dylib)
-- Found PROTOBUF: /usr/local/lib/libprotobuf.dylib
-- Found PROTOBUF Compiler: /usr/local/bin/protoc
-- Found HDF5: /Users/phynix/anaconda/lib/libhdf5_hl.dylib;/Users/phynix/anaconda/lib/libhdf5.dylib (found version "1.8.17")
-- Found LMDB: /usr/local/include
-- Found lmdb    (include: /usr/local/include, library: /usr/local/lib/liblmdb.dylib)
-- Found LevelDB: /usr/local/include
-- Found LevelDB (include: /usr/local/include, library: /usr/local/lib/libleveldb.dylib)
-- Found Snappy: /Users/phynix/anaconda/include
-- Found Snappy  (include: /Users/phynix/anaconda/include, library: /Users/phynix/anaconda/lib/libsnappy.dylib)
-- CUDA detected: 8.0
-- Found cuDNN: ver. 5.1.5 found (include: /usr/local/cuda/include, library: /usr/local/cuda/lib/libcudnn.dylib)
-- Automatic GPU detection failed. Building for all known architectures.
-- Added CUDA NVCC flags for: sm_20 sm_21 sm_30 sm_35 sm_50
-- OpenCV found (/Users/phynix/anaconda/share/OpenCV)
-- Found vecLib: /System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Versions/Current/Headers
-- Found vecLib as part of Accelerate.framework
-- Found PythonInterp: /Users/phynix/anaconda/bin/python2.7 (found suitable version "2.7.12", minimum required is "2.7")
-- Found PythonLibs: /usr/lib/libpython2.7.dylib (found suitable version "2.7.10", minimum required is "2.7")
/Users/phynix/anaconda/bin/python2.7
Python 2.7.12 :: Anaconda custom (x86_64)
-- Found NumPy: /Users/phynix/anaconda/lib/python2.7/site-packages/numpy/core/include (found suitable version "1.11.2", minimum required is "1.7.1")
-- NumPy ver. 1.11.2 found (include: /Users/phynix/anaconda/lib/python2.7/site-packages/numpy/core/include)
-- Boost version: 1.60.0
-- Found the following Boost libraries:
--   python
-- Found Doxygen: /usr/local/bin/doxygen (found version "1.8.12")
-- Detected Doxygen OUTPUT_DIRECTORY: ./doxygen/
-- Found Git: /usr/bin/git (found version "2.9.3 (Apple Git-75)")
--
-- ******************* Caffe Configuration Summary *******************
-- General:
--   Version           :   1.0.0-rc3
--   Git               :   rc3-272-g6491504-dirty
--   System            :   Darwin
--   C++ compiler      :   /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
--   Release CXX flags :   -O3 -DNDEBUG -fPIC -Wall -Wno-sign-compare -Wno-uninitialized
--   Debug CXX flags   :   -g -fPIC -Wall -Wno-sign-compare -Wno-uninitialized
--   Build type        :   Release
--
--   BUILD_SHARED_LIBS :   ON
--   BUILD_python      :   ON
--   BUILD_matlab      :   OFF
--   BUILD_docs        :   ON
--   CPU_ONLY          :   OFF
--   USE_OPENCV        :   ON
--   USE_LEVELDB       :   ON
--   USE_LMDB          :   ON
--   ALLOW_LMDB_NOLOCK :   OFF
--
-- Dependencies:
--   BLAS              :   Yes (vecLib)
--   Boost             :   Yes (ver. 1.60)
--   glog              :   Yes
--   gflags            :   Yes
--   protobuf          :   Yes (ver. 3.1.0)
--   lmdb              :   Yes (ver. 0.9.18)
--   LevelDB           :   Yes (ver. 1.19)
--   Snappy            :   Yes (ver. 1.1.3)
--   OpenCV            :   Yes (ver. 2.4.11)
--   CUDA              :   Yes (ver. 8.0)
--
-- NVIDIA CUDA:
--   Target GPU(s)     :   Auto
--   GPU arch(s)       :   sm_20 sm_21 sm_30 sm_35 sm_50
--   cuDNN             :   Yes (ver. 5.1.5)
--
-- Python:
--   Interpreter       :   /Users/phynix/anaconda/bin/python2.7 (ver. 2.7.12)
--   Libraries         :   /usr/lib/libpython2.7.dylib (ver 2.7.10)
--   NumPy             :   /Users/phynix/anaconda/lib/python2.7/site-packages/numpy/core/include (ver 1.11.2)
--
-- Documentaion:
--   Doxygen           :   /usr/local/bin/doxygen (1.8.12)
--   config_file       :   /Users/phynix/Software/Caffe/caffe/.Doxyfile
--
-- Install:
--   Install path      :   /Users/phynix/Software/Caffe/caffe/cmake_build/install
--
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/phynix/Software/Caffe/caffe/cmake_build

continue...

$ make all                                                                              [13:59:37]
[  0%] Running C++/Python protocol buffer compiler on /Users/phynix/Software/Caffe/caffe/src/caffe/proto/caffe.proto
Scanning dependencies of target proto
[  1%] Building CXX object src/caffe/CMakeFiles/proto.dir/__/__/include/caffe/proto/caffe.pb.cc.o
[  1%] Linking CXX static library ../../lib/libproto.a
[  1%] Built target proto
[  1%] Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile.dir/util/cuda_compile_generated_math_functions.cu.o
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
nvcc fatal   : The version ('80000') of the host compiler ('Apple clang') is not supported
CMake Error at cuda_compile_generated_math_functions.cu.o.cmake:207 (message):
  Error generating

 /Users/phynix/Software/Caffe/caffe/cmake_build/src/caffe/CMakeFiles/cuda_compile.dir/util/./cuda_compile_generated_math_functions.cu.o

@Phynixknight
Copy link
Author

Phynixknight commented Nov 9, 2016

😔...step by step
I didn't use GPU, so after cmake .., one should modified the CmakeCache.txt file

CPU_ONLY:BOOL=ON

or you can modify the CMakeLists.txt

caffe_option(CPU_ONLY  "Build Caffe without CUDA support" ON) # TODO: rename to USE_CUDA

make all

[ 73%] Building CXX object src/caffe/CMakeFiles/caffe.dir/util/upgrade_proto.cpp.o
[ 73%] Linking CXX shared library ../../lib/libcaffe.dylib
Undefined symbols for architecture x86_64:
  "cv::imread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)", referenced from:
      caffe::WindowDataLayer<float>::load_batch(caffe::Batch<float>*) in window_data_layer.cpp.o
      caffe::WindowDataLayer<double>::load_batch(caffe::Batch<double>*) in window_data_layer.cpp.o
      caffe::ReadImageToCVMat(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, int, bool) in io.cpp.o
  "cv::imencode(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cv::_InputArray const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >&, std::__1::vector<int, std::__1::allocator<int> > const&)", referenced from:
      caffe::ReadImageToDatum(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, int, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, caffe::Datum*) in io.cpp.o
ld: symbol(s) not found for architecture x86_64

the solution at this:
#2288

@Phynixknight
Copy link
Author

Phynixknight commented Nov 9, 2016

I modified the caffe/Makefile file by adding

ifeq ($(USE_OPENCV), 1)
    LIBRARIES += opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs

then make clean and make all,but the CMakeCache.txt still didn't have the opencv_imgcodecs, and the same wrong message recieved, where should I add -lopencv_imgcodecs?

The second false trial is to uncomment this line

 Uncomment to use `pkg-config` to specify OpenCV library paths.
# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
# USE_PKG_CONFIG := 1

It's useless. Because conda didn't install opencv on expected way.

Finally, make it right.
The reason is my opencv was installed by anacondaconda install -c menpo opencv=2.4.11.
It's not "make" from source. So pkg-config cannot find the opencv pkg-config --libs --cflags opencv.
So I uninstalled the conda opencv2 and reinstall the opencv by homebrew.

Then, everything goes well.

@Phynixknight Phynixknight changed the title Mac 10.12.1 Sierra Xcode 8.1 cmake.. FAIL Could NOT find NumPy Mac 10.12.1 Sierra Xcode 8.1 cmake 1.vecLib 2.numpy 3.anaconda opencv Nov 11, 2016
@Phynixknight
Copy link
Author

Phynixknight commented Nov 11, 2016

make all...
make install...
make runtest error

[ RUN      ] FilterLayerTest/1.TestGradient
[       OK ] FilterLayerTest/1.TestGradient (286 ms)
[----------] 3 tests from FilterLayerTest/1 (287 ms total)
[----------] 5 tests from ImageDataLayerTest/1, where TypeParam = N5caffe9CPUDeviceIdEE
[ RUN      ] ImageDataLayerTest/1.TestSpace
*** Aborted at 1478843088 (unix time) try "date -d @1478843088" if you are using GNU date ***
PC: @        0x1053bc658 boost::filesystem::path::operator/=()
*** SIGSEGV (@0x0) received by PID 4329 (TID 0x7fff977323c0) stack trace: ***
    @     0x7fff8ec1fbba _sigtramp
    @        0x10d996291 (unknown)
    @        0x10496d8da caffe::MakeTempDir()
    @        0x10498c5d3 caffe::MakeTempFilename()
    @        0x104a176d3 caffe::ImageDataLayerTest<>::SetUp()
    @        0x104bad56a testing::internal::HandleExceptionsInMethodIfSupported<>()
    @        0x104bad367 testing::Test::Run()
    @        0x104bae602 testing::TestInfo::Run()
    @        0x104baeef3 testing::TestCase::Run()
    @        0x104bb5209 testing::internal::UnitTestImpl::RunAllTests()
    @        0x104bb4ce3 testing::internal::HandleExceptionsInMethodIfSupported<>()
    @        0x104bb4c39 testing::UnitTest::Run()
    @        0x104932815 main
    @     0x7fff8ea12255 start
/bin/sh: line 1:  4329 Segmentation fault: 11  /Users/phynix/Software/Caffe/caffe/cmake_build/test/test.testbin --gtest_shuffle --gtest_filter="-*GPU*"
make[3]: *** [src/caffe/test/CMakeFiles/runtest] Error 139
make[2]: *** [src/caffe/test/CMakeFiles/runtest.dir/all] Error 2
make[1]: *** [src/caffe/test/CMakeFiles/runtest.dir/rule] Error 2

The solution is at #1993

This is a result of the logging library (glog) that shows this when a failure happens.[Quote]
So many different reasons can cause this problem.

@Phynixknight Phynixknight changed the title Mac 10.12.1 Sierra Xcode 8.1 cmake 1.vecLib 2.numpy 3.anaconda opencv Mac 10.12.1 Sierra Xcode 8.1 cmake error (1).not Found vecLib (2).ImportError: No module named numpy (3).Undefined symbols for architecture x86_64 (4).Aborted at (unix time) using GNU date Nov 14, 2016
@Phynixknight Phynixknight changed the title Mac 10.12.1 Sierra Xcode 8.1 cmake error (1).not Found vecLib (2).ImportError: No module named numpy (3).Undefined symbols for architecture x86_64 (4).Aborted at (unix time) using GNU date Mac 10.12.1 Sierra Xcode 8.1 cmake error (1).not Found vecLib (2).ImportError: No module named numpy (3).Undefined symbols for architecture x86_64 cv::imread(std::__1::basic_string (4).Aborted at (unix time) using GNU date Nov 14, 2016
@Phynixknight Phynixknight changed the title Mac 10.12.1 Sierra Xcode 8.1 cmake error (1).not Found vecLib (2).ImportError: No module named numpy (3).Undefined symbols for architecture x86_64 cv::imread(std::__1::basic_string (4).Aborted at (unix time) using GNU date Mac 10.12.1 Sierra Xcode 8.1 cmake error (1).not Found vecLib (2).ImportError: No module named numpy (3).Undefined symbols for architecture x86_64 cv::imread(std::__1::basic_string (4) make runtest. Aborted at (unix time) using GNU date Nov 14, 2016
@Phynixknight
Copy link
Author

Phynixknight commented Nov 15, 2016

I cannot find the reason above, so I use make instead of cmake.
When I make all, an error shows

clang: warning: argument unused during compilation: '-pthread'
ld: library not found for -lboost_thread-mt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [.build_release/lib/libcaffe.so] Error 1

That's Because I install boost by anaconda as I mentioned before, conda install boost, so the boost is not compile from source and without boost-thread.
http://stackoverflow.com/questions/34589573/error-installing-caffe
There are at least two methods to solve this problem.

1. cd "anacondaHOME";cp libboost_thread.dylib libboost_thread-mt.dylib
2.conda uninstall boost boost-python then
 brew install --build-from-source -vd boost boost-python

I use the first method, and it goes well for make all and make test
but when make runtest

.build_release/tools/caffe
dyld: Library not loaded: @rpath/./libboost_system.dylib
  Referenced from: /Users/phynix/Software/Caffe/caffe/.build_release/tools/caffe
  Reason: image not found
make: *** [runtest] Abort trap: 6

Then I reinstall the boost by homebrew, and another Libray not loaded(hdf5), also hdf5 is installed by anaconda. So I also reinstalled hdf5 by homebrew, and another Library not loaded dyld: Library not loaded: @rpath/libmkl_rt.dylib.

So all the errors like above are caused by the Library not found, First anaconda installed library cannot found (Even though I have add all the necessary env, indeed I tried to commen and uncommen all the not necessary env in Makefile.config and .bash_profile like adding all anaconda lib dirs to LD_xxx pythonlibxxx PKG-configxxx dirs , but the result is the same), Second other library cannot found like mkl( Though I have source /opt/intel/mkl/bin/mklvars.sh intel64).

## Refer to http://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving our build system are welcome!

# cuDNN acceleration switch (uncomment to build with cuDNN).
# USE_CUDNN := 1

# CPU-only switch (uncomment to build without GPU support).
CPU_ONLY := 1

# uncomment to disable IO dependencies and corresponding data layers
# USE_OPENCV := 0
# USE_LEVELDB := 0
# USE_LMDB := 0

# uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)
#   You should not set this flag if you will be reading LMDBs with any
#   possibility of simultaneous read and write
# ALLOW_LMDB_NOLOCK := 1

# Uncomment if you're using OpenCV 3
# OPENCV_VERSION := 3

# To customize your choice of compiler, uncomment and set the following.
# N.B. the default for Linux is g++ and the default for OSX is clang++
# CUSTOM_CXX := g++

# CUDA directory contains bin/ and lib/ directories that we need.
CUDA_DIR := /usr/local/cuda
# On Ubuntu 14.04, if cuda tools are installed via
# "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
# CUDA_DIR := /usr

# CUDA architecture setting: going with all of them.
# For CUDA < 6.0, comment the *_50 lines for compatibility.
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
        -gencode arch=compute_20,code=sm_21 \
        -gencode arch=compute_30,code=sm_30 \
        -gencode arch=compute_35,code=sm_35 \
        -gencode arch=compute_50,code=sm_50 \
        -gencode arch=compute_50,code=compute_50

# BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
#BLAS := atlas
BLAS := mkl
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
# BLAS_INCLUDE := /path/to/your/blas
# BLAS_LIB := /path/to/your/blas

BLAS_INCLUDE := /opt/intel/mkl/include
BLAS_LIB := /opt/intel/mkl/lib

# Homebrew puts openblas in a directory that is not on the standard search path
# BLAS_INCLUDE := $(shell brew --prefix openblas)/include
# BLAS_LIB := $(shell brew --prefix openblas)/lib

# This is required only if you will compile the matlab interface.
# MATLAB directory should contain the mex binary in /bin.
# MATLAB_DIR := /usr/local
# MATLAB_DIR := /Applications/MATLAB_R2012b.app

# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
#PYTHON_INCLUDE := /usr/include/python2.7 \
        /usr/lib/python2.7/dist-packages/numpy/core/include
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location, sometimes it's in root.
ANACONDA_HOME := $(HOME)/anaconda
PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
        $(ANACONDA_HOME)/include/python2.7 \
        $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include

# Uncomment to use Python 3 (default is Python 2)
# PYTHON_LIBRARIES := boost_python3 python3.5m
# PYTHON_INCLUDE := /usr/include/python3.5m \
#                 /usr/lib/python3.5/dist-packages/numpy/core/include

# We need to be able to find libpythonX.X.so or .dylib.
#PYTHON_LIB := /usr/lib
PYTHON_LIB := $(ANACONDA_HOME)/lib

# Homebrew installs numpy in a non standard path (keg only)
PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include
PYTHON_LIB += $(shell brew --prefix numpy)/lib

# Uncomment to support layers written in Python (will link against Python libs)
# WITH_PYTHON_LAYER := 1

# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib

# If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
INCLUDE_DIRS += $(shell brew --prefix)/include
LIBRARY_DIRS += $(shell brew --prefix)/lib

# Uncomment to use `pkg-config` to specify OpenCV library paths.
# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
#USE_PKG_CONFIG := 1

# N.B. both build and distribute dirs are cleared on `make clean`
BUILD_DIR := build
DISTRIBUTE_DIR := distribute

# Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
# DEBUG := 1

# The ID of the GPU that 'make runtest' will use to run unit tests.
TEST_GPUID := 0

# enable pretty build (comment to see full commands)
Q ?= @

`

@Phynixknight
Copy link
Author

Finally, I Make through.
What did I do?
Uninstall most of the necessary libs , protobuf, boost, boost-python, cmake,etc. in anaconda and reinstall them by homebrew.
Then the make runtest shows

cannot find lib libmklxxxx.dylib

as I mentioned above, I have set the mkl evn in the right way in Makefile.config

BLAS_INCLUDE := /opt/intel/mkl/include
BLAS_LIB := /opt/intel/mkl/lib

and in envsource /opt/intel/mkl/bin/mklvars.sh intel64
But it still not right, I will resolve it later.
So I set the BLAS to atlas, then everything goes well, cheer.

@yiakwy
Copy link

yiakwy commented Jan 27, 2017

I am angry because in the source code in cmake(cmake/Modules/Summary.cmake):

caffe_status(" BLAS : " APPLE THEN "Yes (vecLib)" ELSE "Yes (${BLAS})")

That means that if you use APPLE, then you are not able to use ${BLAS} as what you set to.

@yiakwy
Copy link

yiakwy commented Jan 27, 2017

I am the user of MKL , but the author of the packages said that

@

# ---[ BLAS
if(NOT APPLE)
  set(BLAS "Atlas" CACHE STRING "Selected BLAS library")
  set_property(CACHE BLAS PROPERTY STRINGS "Atlas;Open;MKL")

  if(BLAS STREQUAL "Atlas" OR BLAS STREQUAL "atlas")
    find_package(Atlas REQUIRED)
    include_directories(SYSTEM ${Atlas_INCLUDE_DIR})
    list(APPEND Caffe_LINKER_LIBS ${Atlas_LIBRARIES})
  elseif(BLAS STREQUAL "Open" OR BLAS STREQUAL "open")
    find_package(OpenBLAS REQUIRED)
    include_directories(SYSTEM ${OpenBLAS_INCLUDE_DIR})
    list(APPEND Caffe_LINKER_LIBS ${OpenBLAS_LIB})
  elseif(BLAS STREQUAL "MKL" OR BLAS STREQUAL "mkl")
    find_package(MKL REQUIRED)
    include_directories(SYSTEM ${MKL_INCLUDE_DIR})
    list(APPEND Caffe_LINKER_LIBS ${MKL_LIBRARIES})
    add_definitions(-DUSE_MKL)
  endif()
elseif(APPLE)
  find_package(vecLib REQUIRED)
  include_directories(SYSTEM ${vecLib_INCLUDE_DIR})
  list(APPEND Caffe_LINKER_LIBS ${vecLib_LINKER_LIBS})

  if(VECLIB_FOUND)
    if(NOT vecLib_INCLUDE_DIR MATCHES "^/System/Library/Frameworks/vecLib.framework.*")
      add_definitions(-DUSE_ACCELERATE)
    endif()
  endif()
endif()

Oh that means if you are a user of apple, you can only use vecLib. Otherwise, you can BLAS try what you have set to.

@shelhamer
Copy link
Member

On OS X I always compile with the Makefile build. I have not been able to make CMake compile correctly. Please ask installation questions on the mailing list.

From https://github.com/BVLC/caffe/blob/master/CONTRIBUTING.md:

Please do not post usage, installation, or modeling questions, or other requests for help to Issues.
Use the caffe-users list instead. This helps developers maintain a clear, uncluttered, and efficient view of the state of Caffe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants