导入caffe时出错

时间:2016-02-17 15:53:52

标签: python machine-learning caffe pycaffe

对于DeepDream或其他深度学习项目,构建Caffe的环境。

我为PyCaffe安装了必需的软件包,并将PYTHONPATH用于caffe / python。

然而,当我在python上导入caffe:

import caffe

发生错误如下。如何解决此问题?

Segmentation fault: 11

3 个答案:

答案 0 :(得分:1)

你使用的是mac吗?我很难在mac上制作pycaffe,直到我意识到所有mac上都安装了一个本机python并且我正在使用我安装的另一个版本。在编译时,caffe正在使用本机python中的一些东西,以及来自其他python的一些东西。我必须确保更改makefile.config文件中的所有相关路径并更改我的bash正在使用的python。我也建议在虚拟环境中工作。 This是一个很好的链接,可以帮助你,祝你好运!

答案 1 :(得分:1)

自2015年以来Github issue已对此进行了讨论。 主要原因是自制python和OS X系统python的冲突。

Homebrew提供了awesome solution for OS X

$ python -V   # system Python interpreter
$ python2 -V  # Homebrew installed Python 2 interpreter
$ python3 -V  # Homebrew installed Python 3 interpreter (if installed)

因此解决方案是将所有python路径更改为python2。 Bellowing是我的Makefile.config相关:

# ...
# 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
# ------ For Homebrew installed python. Numpy path is added using python commands. 
PYTHON_INCLUDE := /usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/include/python2.7

# We need to be able to find libpythonX.X.so or .dylib. ------ (Update Homebrew path)
# PYTHON_LIB := /usr/lib
# PYTHON_LIB := $(ANACONDA_HOME)/lib
PYTHON_LIB := /usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib

# Homebrew installs numpy in a non standard path (keg only) ------ (python2 for brew instead of python for system)
PYTHON_INCLUDE += $(dir $(shell python2 -c 'import numpy.core; print(numpy.core.__file__)'))/include
PYTHON_LIB += $(shell brew --prefix numpy)/lib
# ...

答案 2 :(得分:0)

如果没有名为caffe error的模块

,请尝试在python脚本中手动设置python路径

实施例。 import sys

sys.path.insert(0,“/ home / nviso / GitHub / caffe / distribute / python”)

导入caffe

这通常对我有用。 手动添加.bashrc的caffe或python路径应该可以解决问题,但不确定,现在不要让我的Office PC尝试:)

相关问题