赞
踩
表格中列举了我试验成功的所有依赖包及其对应版本号,部分依赖包可能和官方文档中所推荐的不同。经本人验证,caffe编译过程中所需的依赖包版本相互之间有严重的依赖关系,当然其他版本可能也能正常运行,但如果想节省时间的话,不妨试试以下这些吧~
Description | ||
Protobuf | 3.6.0 | Protocol Buffers - Google's data interchange format. |
Leveldb | 1.20 | LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values. |
Snappy | 1.1.6 | A fast compressor/decompressor. |
Opencv | 3.3.1 | Open Source Computer Vision Library. |
Boost | 1.56.0 | Boost provides free peer-reviewed portable C++ source libraries. |
Atlas | 3.8.4 | 线性代数库 |
Gflags | 2.1.2 | The gflags package contains a C++ library that implements commandline flags processing. |
Glog | 0.3.3 | Google logging module |
Lmdb | 0.9.18 | 轻量级内存映射数据库 |
- ./autogen.sh
-
- ./configure --prefix=/path/to/install
-
- make
-
- make check
-
- make install
-
- protoc --version #检查是否安装成功
Python binding安装(这样可以确保caffe和pycaffe使用的是同一版protobuf)
- cd $root/python
-
- python setup.py build
-
- python setup.py install
- make -j8
-
- cp -r include/* path_to_install/include/
-
- cp out-shared/* path_to_install/lib/
- mkdir build
-
- cd build
-
- export CXXFLAGS="-fPIC”
- cmake .. -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=/path/to/install
- make VERBOSE=1
- make -j8
- make install
- ./configure --prefix=/path/to/install
-
- make -j8
-
- make install
- ./bootstrap.sh --prefix=path/to/install
-
- ./b2 install
- mkdir build
-
- cd build
-
- cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/path/to/install
-
- make -j8
-
- make install
- ./configure --prefix=/path/to/install
-
- make
-
- make install
- cd lmdb-xxx/libraries/liblmdb
-
- # 修改29行:prefix=/path/to/install
- vim Makefile
-
- make
-
- make install
编译—caffe:
- # Step1:备份makefile.config --------------
-
- cp Makefile.config.example Makefile.config
-
- # ----------------------------------------
-
-
-
-
-
- # Step2:根据自己的路径 对makefile.config进行相应修改 ----------------------------------------------
-
-
-
- # 因为我们使用的是OpenCV3,所以需要取消注释
-
- # Uncomment if you're using OpenCV 3
-
- OPENCV_VERSION := 3
-
-
-
- # 设置CUDA路径,若编译CPU版,则需要打开CPU_ONLY选项
-
- # CUDA directory contains bin/ and lib/ directories that we need.
-
- CUDA_DIR := /usr/local/cuda
-
-
-
- # 设置Python头文件路径,主要是Python.h和numpy头文件
-
- # We need to be able to find Python.h and numpy/arrayobject.h.
-
- PYTHON_INCLUDE := /home/conda/include/python2.7/ \
-
- /home/conda/lib/python2.7/site-packages/numpy/core/include
-
-
-
- # 设置Python库目录
-
- # We need to be able to find libpythonX.X.so or .dylib.
-
- PYTHON_LIB := /home/conda/lib
-
-
-
- # 设置其他依赖包的头文件路径和库目录
-
- # Whatever else you find you need goes here.
-
- INCLUDE_DIRS := $(PYTHON_INCLUDE) /home/local/include
-
- LIBRARY_DIRS := $(PYTHON_LIB) /home/local/lib
-
-
- #------------------------------------------------------------------------------------------------
-
-
-
- # Step3: 编译 --------------
-
- make all -j8
-
- make test
-
- make runtest
-
- #---------------------------

编译—pycaffe
- make pycaffe
-
- export PYTHONPATH=$caffe_root/python:$PYTHONPATH
Q1: 在python中import caffe时,提示"No module named google.protobuf.internal"
A: 卸载掉现在的protobuf,参考2.1重新安装。
Q2: xxx/libstdc++.so.6: version `CXXABI_1.3.9' not found
A: 参考https://blog.csdn.net/zx714311728/article/details/69628836
Q3: ImportError: numpy.core.multiarray failed to import
A: 卸载numpy,重新安装一个版本号>1.14的numpy
Q4: import caffe 时出现Intel MKL FATAL ERROR: Cannot load libmkl_avx2.so
A: 参考https://blog.csdn.net/u010335339/article/details/51501246
Q5: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
A: 说明所使用的编译器默认不是C++11标准,需要修改caffe/Makefile相应位置,添上-std=c++11选项。具体有以下几处:
- # <caffe/Makefile>
-
-
- 414 CXXFLAGS += -pthread -fPIC -std=c++11 $(COMMON_FLAGS) $(WARNINGS)
- 415 NVCCFLAGS += -ccbin=$(CXX) -Xcompiler -fPIC -std=c++11 $(COMMON_FLAGS)
-
-
- 507 @ echo CXX/LD -o $@ $<
- 508 $(Q)$(CXX) -shared -o $@ $(PY$(PROJECT)_SRC) \
- 509 -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(PYTHON_LDFLAGS) \
- 510 -Wl,-rpath,$(ORIGIN)/../../build/lib -std=c++11
-
-
- 572 @ echo LD -o $@
- 573 $(Q)$(CXX) -shared -o $@ $(OBJS) $(VERSIONFLAGS) $(LINKFLAGS) $(LDFLAGS) -std=c++11
-
-
- 603 @ echo CXX/LD -o $@ $<
- 604 $(Q)$(CXX) $(TEST_MAIN_SRC) $(TEST_OBJS) $(GTEST_OBJ) \
- 605 -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib -std=c++11
-
-
- 609 @ echo LD $<
- 610 $(Q)$(CXX) $(TEST_MAIN_SRC) $< $(GTEST_OBJ) \
- 611 -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib -std=c++11
-
-
- 615 @ echo LD $<
- 616 $(Q)$(CXX) $(TEST_MAIN_SRC) $< $(GTEST_OBJ) \
- 617 -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib -std=c++11
-
-
- 625 @ echo CXX/LD -o $@
- 626 $(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(LDFLAGS) \
- 627 -Wl,-rpath,$(ORIGIN)/../lib -std=c++11
-
-
- 630 @ echo CXX/LD -o $@
- 631 $(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(LDFLAGS) \
- 632 -Wl,-rpath,$(ORIGIN)/../../lib -std=c++11

Q6: 在编译MobileNet-Yolo时遇到这样的问题:opencv-3.3.1/lib/libopencv_videoio.so.3.3: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [.build_release/examples/ssd/ssd_detect.bin] Error 1
A: 因为Makefile里有个小bug,在使用OpenCV3时少引了一个库,在Makefile的第198行后面添上opencv_videoio即可。
Q7: 编译caffe-ssd时遇到如下问题:/lib/libcaffe.so: undefined reference to `boost::re_detail::cpp_regex_traits_implementation<char>::transform(char constmake: *** [.build_release/tools/upgrade_net_proto_binary.bin] Error 1
*, char const*) const'
A: 在Makefile第181行后面添加boost_regex
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。