mac系统:10.12.6
python:自己安装,非mac自带python
前置条件:编译pycaffe成功
问题:import caffe执行时候崩溃Segmentation fault...
Process: Python [15242]
Path: /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: 2.7.13 (2.7.13)
CodeType: X86-64 (Native)
ParentProcess: bash [3757]
Responsible: Python [15242]
User ID: 501
解决方案:网上解决的一大堆,但是大都无法真正解决。主要原因在于mac自带python和自己装的python在编译和运行时冲突了,打开 Makefile.config,做出如下修改
PYTHON_LIB := /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib
然后重新编译代码:
$ make clean
$ make
$ make pycaffe
$ make distribute
测试代码:
import sys
caffe_root = '/Users/XXX/caffe/'
sys.path.append(caffe_root + 'python')
import caffe
若出现如下错误,
import skimage.io ImportError: No module named skimage.io
可能是没有安装skimage.io 模块,用以下的命令来安装:
$ sudo pip install scikit-image
总而言之,mac + python + caffe 就是蛋疼....... Orz...
python 突然报错 src/tcmalloc.cc:331] Attempt to free invalid pointer 0x7fcca4d01a00 [1....
尝试更换一下import的顺序,把import caffe 尽量提前