配置 Caffe 可能出现的问题
1. 如果出现如下问题:
from caffe.proto import caffe_pb2
ImportError: No module named caffe.proto
则通常说明要配置PYTHONPATH环境变量:
Export PYTHONPATH=/usr/lib/python2.7/dist-packages:/home/xxx/caffe/ python
2. 如果出现如下问题:
File “/usr/lib/python2.7/dist-packages/numpy/init.py”, line 153, in
from . import add_newdocs
File “/usr/lib/python2.7/dist-packages/numpy/add_newdocs.py”, line 13, in
from numpy.lib import add_newdoc
File “/usr/lib/python2.7/dist-packages/numpy/lib/init.py”, line 22, in
from .npyio import *
File “/usr/lib/python2.7/dist-packages/numpy/lib/npyio.py”, line 4, in
from . import format
File “/usr/lib/python2.7/dist-packages/numpy/lib/format.py”, line 141, in
import io
File “/home/swami/packages_local/caffe/python/caffe/io.py”, line 2, in
import http://skimage.io
File “/usr/local/lib/python2.7/dist-packages/skimage/init.py”, line 171, in
from .util.dtype import *
File “/usr/local/lib/python2.7/dist-packages/skimage/util/init.py”, line 1, in
from .dtype import (img_as_float, img_as_int, img_as_uint, img_as_ubyte,
File “/usr/local/lib/python2.7/dist-packages/skimage/util/dtype.py”, line 8, in
dtype_range = {np.bool_: (False, True),
AttributeError: ‘module’ object has no attribute ‘bool_’
则说明你的PYTHONPATH环境变量配置不对:
解决问题如下:
a) You need to have _caffe.so in caffe/python/caffe. If not, run ‘make pycaffe’ in caffe source folder.
b) You need to add only caffe/python to $PYTHONPATH but not caffe/python/caffe as mentioned in documentation. I don’t know why adding caffe/python/caffe causes the error, though.
3. 在配置环境变量的时候(.bahsrc),务必关闭 tmux,欲哭无泪啊。配置完后用 echo 把环境变量打印出来以确认是否配置成功。