我使用Python 2.7.14在MacOS 10.13.3(17D47)上。我正在构建caffe w / python。该项目仅限CPU。我可以通过make run test
构建caffe但是,在尝试make pycaffe
后我收到错误。这是结果:
touch python/caffe/proto/__init__.py
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
PROTOC (python) src/caffe/proto/caffe.proto
In file included from python/caffe/_caffe.cpp:17:
In file included from ./include/caffe/caffe.hpp:12:
./include/caffe/net.hpp:41:5: warning: unused typedef 'INVALID_REQUESTED_LOG_SEVERITY' [-Wunused-local-typedef]
LOG_EVERY_N(WARNING, 1000) << "DEPRECATED: ForwardPrefilled() "
^
/usr/local/include/glog/logging.h:943:30: note: expanded from macro 'LOG_EVERY_N'
INVALID_REQUESTED_LOG_SEVERITY); \
^
1 warning generated.
ld: library not found for -lboost_python
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [python/caffe/_caffe.so] Error 1
我有一个Makefile.config,它从brew安装集中调用boost-python:
# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/local/Cellar/boost-python/1.67.0/lib
我的两个初步问题是: 1)我不允许使用系统python链接到boost库? 2)告诉make获取boost-python的正确方法是什么?
答案 0 :(得分:4)
我实际上遇到了同样的问题,几天都找不到任何答案。但是,我发现了这个问题:Build caffe with Python ( cannot find -lboost_python3 )。
这个问题适用于python3,但我使用的是python2.7。基本上,我进入了Makefile(不是Makefile.config),搜索了boost_python
,并将其更改为boost_python27
。我做了以下步骤:
vim Makefile
use vim command :?boost_python
(应该只有1次出现)changed PYTHON_LIBRARIES ?= boost_python python2.7
to PYTHON_LIBRARIES ?= boost_python27 python2.7
sudo make pycaffe
我希望这可以帮到你!
答案 1 :(得分:2)
转到Makefile(而不是.config文件)并将ld库的名称更改为python27。