主要是因为之前只用了anaconda3,编译pycaffe之后,版本不太兼容()。
这里是caffe官网的原文
Caffe’s Python interface works with Python 2.7. Python 3.3+ should work out of the box without protobuf support. For protobuf support please install protobuf 3.0 alpha (https://developers.google.com/protocol-buffers/). Earlier Pythons are your own adventure
之后重新装了anaconda2
这里觉得比较保险的配置过程是先编译caffe
再使用指令验证是否能正常加载Python库
import caffe
值得一提的是使用makefile.config
1. 修改一下CUDA的编译选项
#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_52,code=sm_52 \ # -gencode arch=compute_60,code=sm_60 \ # -gencode arch=compute_61,code=sm_61 \ # -gencode arch=compute_61,code=compute_61 CUDA_ARCH := -gencode arch=compute_30,code=sm_30
# 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)/anaconda2 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
gedit ~/.bashrc
#caffe path #export PYTHONPATH=/home/billbliss/caffe/python:$PYTHONPATH
接下来也是一样的方式配置ssd-caffe
使用makefile.config
1. 修改一下CUDA的编译选项
2. 修改python库的编译 指向anaconda
3. 修改环境变量#ssd path export PYTHONPATH=/home/billbliss/ssd/caffe/python:$PYTHONPATH