我按照BVLC\caffe针对Windows Caffe的说明,通过scripts\build_win.cmd
(CPU_ONLY=1
,BUILD_PYTHON=1
,BUILD_PYTHON_LAYER=1
)成功构建了caffe。
然后,将C:\Projects\caffe\python\caffe
文件夹复制到我的site_packages
文件夹[...]\Anaconda3\Lib\site-packages
中。
我正在使用Anaconda 4.2.0,并且根据需要将Python 3.5
用于caffe。
但是现在它无法导入caffe,我也不明白为什么,因为我看到的所有情况都是关于没有为python编译的(我假设是由BUILD_PYTHON=1
标志完成的)将python\caffe
文件夹复制到site-packages
文件夹中。
这是错误输出:
>>> import caffe
ImportError: numpy.core.multiarray failed to import
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Projects\anaconda\Anaconda3\lib\site-packages\caffe\__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
File "C:\Projects\anaconda\Anaconda3\lib\site-packages\caffe\pycaffe.py", line 13, in <module>
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
SystemError: initialization of _caffe raised unreported exception
即使我尝试将C:\Projects\caffe\python
文件夹添加到python路径中,从我所看到的来看这也不是一个好主意,但它仍然会失败,出现同样的错误:
>>> import sys
>>> sys.path.insert(0, "C:\Projects\caffe\python")
>>> import caffe
ImportError: numpy.core.multiarray failed to import
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Projects\caffe\python\caffe\__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
File "C:\Projects\caffe\python\caffe\pycaffe.py", line 13, in <module>
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
SystemError: initialization of _caffe raised unreported exception
也许我错过了一些事情,希望有人能看到并能提供帮助。 谢谢。