caffe过程中的错误(二)

来源:互联网 发布:蚁群算法公式解析 编辑:程序博客网 时间:2024/05/20 01:12

1、安装anaconda

先到https://www.continuum.io/downloads 下载anaconda,现在的版本有python2.7版本和python3.5版本,下载好对应版本、对应系统的anaconda

下载成功后,在终端执行(2.7版本):

# bash Anaconda2-2.4.1-Linux-x86_64.sh

或者3.5 版本:

# bash Anaconda3-2.4.1-Linux-x86_64.sh


安装完anaconda2后显示command not found: Anaconda2

 vi ~/.bashrc

export PATH="/Users/muaxiu/anaconda2/bin:$PATH"

 source ~/.bashrc


输入conda list

列出所有安装包的版本



(1)make: Nothing to be done for `all'.

重新make clean

make all

(2)报错:

  make all

PROTOC src/caffe/proto/caffe.proto

CXX .build_release/src/caffe/proto/caffe.pb.cc

CXX src/caffe/blob.cpp

CXX src/caffe/common.cpp

CXX src/caffe/data_transformer.cpp

CXX src/caffe/internal_thread.cpp

CXX src/caffe/layer.cpp

CXX src/caffe/layer_factory.cpp

In file included from src/caffe/layer_factory.cpp:4:

In file included from /usr/local/include/boost/python.hpp:11:

In file included from /usr/local/include/boost/python/args.hpp:8:

In file included from /usr/local/include/boost/python/detail/prefix.hpp:13:

/usr/local/include/boost/python/detail/wrap_python.hpp:50:11: fatal error: 'pyconfig.h' file not found

# include <pyconfig.h>

          ^

1 error generated.

make: *** [.build_release/src/caffe/layer_factory.o] Error 1


论坛找到方法,三步骤:

make clean

export CPLUS_INCLUDE_PATH=/usr/include/python2.7

make all


打开/usr/include/python2.7文件,可以看见pyconfig.h文件

后续make只有警告没有错


(3)make runtest出现问题:

Warning! ***HDF5 library version mismatched error***

The HDF5 header files used to compile this application do not match

the version used by the HDF5 library to which this application is linked.

Data corruption or segmentation faults may occur if the application continues.

This can happen when an application was compiled by one version of HDF5 but

linked with a different version of static or shared HDF5 library.

You should recompile the application or check your shared library related

settings such as 'LD_LIBRARY_PATH'.

You can, at your own risk, disable this warning by setting the environment

variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'.

Setting it to 2 or higher will suppress the warning messages totally.

Headers are 1.8.17, library is 1.10.1

    SUMMARY OF THE HDF5 CONFIGURATION

    =================================


General Information:

-------------------

                   HDF5 Version: 1.10.1

                  Configured on: Wed May 10 20:46:51 BST 2017

                  Configured by: brew@Sierra.local

                    Host system: x86_64-apple-darwin16.5.0

              Uname information: Darwin Sierra.local 16.5.0 Darwin Kernel Version 16.5.0: Fri Mar 3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64

                       Byte sex: little-endian

             Installation point: /usr/local/Cellar/hdf5/1.10.1


Compiling Options:

------------------

                     Build Mode: production

              Debugging Symbols: no

                        Asserts: no

                      Profiling: no

             Optimization Level: high


Linking Options:

----------------

                      Libraries: static, shared

  Statically Linked Executables: 

                        LDFLAGS: 

                     H5_LDFLAGS: 

                     AM_LDFLAGS: -L/usr/lib -L/usr/local/opt/szip/lib

                Extra libraries: -lsz -lz -ldl -lm 

                       Archiver: ar

                         Ranlib: ranlib


Languages:

----------

                              C: yes

                     C Compiler: /usr/local/Homebrew/Library/Homebrew/shims/super/clang ( Apple LLVM version 8.1.0 )

                       CPPFLAGS: 

                    H5_CPPFLAGS:   -DNDEBUG -UH5_DEBUG_API

                    AM_CPPFLAGS: -I/usr/include -I/usr/local/opt/szip/include

                        C Flags: 

                     H5 C Flags:     

                     AM C Flags: 

               Shared C Library: yes

               Static C Library: yes



                        Fortran: no


                            C++: yes

                   C++ Compiler: /usr/local/Homebrew/Library/Homebrew/shims/super/clang++ ( Apple LLVM version 8.1.0 )

                      C++ Flags: 

                   H5 C++ Flags:    

                   AM C++ Flags: 

             Shared C++ Library: yes

             Static C++ Library: yes


                           Java: no



Features:

---------

                  Parallel HDF5: no

             High-level library: yes

                   Threadsafety: no

            Default API mapping: v110

 With deprecated public symbols: yes

         I/O filters (external): deflate(zlib),szip(encoder)

                            MPE: no

                     Direct VFD: no

                        dmalloc: no

 Packages w/ extra debug output: none

                    API tracing: no

           Using memory checker: no

Memory allocation sanity checks: no

            Metadata trace file: no

         Function stack tracing: no

      Strict file format checks: no

   Optimization instrumentation: no

Bye...

*** Aborted at 1499695537 (unix time) try "date -d @1499695537" if you are using GNU date ***

PC: @     0x7fff8cab1d42 __pthread_kill

*** SIGABRT (@0x7fff8cab1d42) received by PID 48362 (TID 0x7fff9589d3c0) stack trace: ***

    @     0x7fff8cb92b3a _sigtramp

    @        0x100000001 (unknown)

    @     0x7fff8ca17420 abort

    @        0x10a008f61 H5check_version

    @        0x10ab096de caffe::HDF5DataLayer<>::LoadHDF5FileData()

    @        0x10ab08a4c caffe::HDF5DataLayer<>::LayerSetUp()

    @        0x10ab65a97 caffe::Net<>::Init()

    @        0x10ab647fe caffe::Net<>::Net()

    @        0x10ab7c1fa caffe::Solver<>::InitTrainNet()

    @        0x10ab7b5d1 caffe::Solver<>::Init()

    @        0x10ab7b2d5 caffe::Solver<>::Solver()

    @        0x1096e4596 caffe::SGDSolver<>::SGDSolver()

    @        0x1096f2f3b caffe::NesterovSolverTest<>::InitSolver()

    @        0x1096df96a caffe::GradientBasedSolverTest<>::InitSolverFromProtoString()

    @        0x1096e0568 caffe::GradientBasedSolverTest<>::RunLeastSquaresSolver()

    @        0x1096dfdf5 caffe::GradientBasedSolverTest<>::TestLeastSquaresUpdate()

    @        0x10989ebe7 testing::internal::HandleExceptionsInMethodIfSupported<>()

    @        0x10989ea4a testing::Test::Run()

    @        0x10989fbbe testing::TestInfo::Run()

    @        0x1098a04b7 testing::TestCase::Run()

    @        0x1098a60b7 testing::internal::UnitTestImpl::RunAllTests()

    @        0x1098a5b93 testing::internal::HandleExceptionsInMethodIfSupported<>()

    @        0x1098a5af9 testing::UnitTest::Run()

    @        0x1095d1fc5 main

    @     0x7fff8c983235 start

make: *** [runtest] Abort trap: 6


尝试:

1)更新hdf5:

conda update hdf5

问题继续

2conda remove hdf5

conda install hdf5

问题继续

3)conda install -c anaconda hdf5=1.8.17

问题依旧

4)conda remove hdf5

make runtest 编译没错

conda list

grin       1.2.1         py27_3  

heapdict   1.0.0         py27_1  

html5lib   0.999         py27_0  

icu        54.1          0  


已经没有hdf5




(4) make pycaffe报错:

  make pycaffe

CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp

python/caffe/_caffe.cpp:10:10: fatal error:'numpy/arrayobject.h' file not found

#include <numpy/arrayobject.h>

         ^

1 error generated.

make: *** [python/caffe/_caffe.so] Error 1


Makefile.config里改PYTHON_INCLUDE

ANACONDA_HOME := $(HOME)/anaconda2

PYTHON_INCLUDE := $(ANACONDA_HOME)/include \

$(ANACONDA_HOME)/include/python2.7 \

$(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include


这几段中最后两行前的#忘记去掉了= =!宛如一个智障



为防止错误,再编译

make test -j8

make runtest -j8

截取最后:

[ RUN      ] EltwiseLayerTest/0.TestSumCoeff

[       OK ] EltwiseLayerTest/0.TestSumCoeff (0 ms)

[ RUN      ] EltwiseLayerTest/0.TestSumGradient

[       OK ] EltwiseLayerTest/0.TestSumGradient (3 ms)

[ RUN      ] EltwiseLayerTest/0.TestProd

[       OK ] EltwiseLayerTest/0.TestProd (1 ms)

[ RUN      ] EltwiseLayerTest/0.TestSum

[       OK ] EltwiseLayerTest/0.TestSum (0 ms)

[ RUN      ] EltwiseLayerTest/0.TestSumCoeffGradient

[       OK ] EltwiseLayerTest/0.TestSumCoeffGradient (3 ms)

[----------] 10 tests from EltwiseLayerTest/0 (19 ms total)


[----------] Global test environment tear-down

[==========] 1106 tests from 150 test cases ran. (51570 ms total)

[  PASSED  ] 1106 tests.



(5)在Python环境下import caffe

报错:Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

ImportError: No module named caffe


重新

vi /etc/profile

source /etc/profile

import caffe 成功


2、安装jupyter

jupyter --version

LZ 已经安装了Anaconda2,其自带jupter,就查了一下版本,如果你没有那么sudo pip install jupyter

安装一下】


jupyter notebook


(1)重新开了终端后发现

  jupyter notebook

zsh: command not found: jupyter

修改路径

 vi ~/.bashrc

export PATH=$PATH:~/.local/bin

 source ~/.bashrc

后在终端 jupyter notebook成功


(2)但是显示:

0:97: execution error: “"http://localhost:8888/tree?token=e380fd72952f4c4a3005536bdc91b4e02ef2a4c240bd3287"”不理解“open location”信息。 (-1708)


~/.jupyter目录下创建文件jupyter_notebook_config.py,文件内容如下:

c.NotebookApp.browser = u'Google Chrome'

c.NotebookApp.token = ''

c.NotebookApp.password = ''


但是根本找不到~/.jupyter!!!


默认打开Jupyter notebook,工作目录是C:\Users\Username

我的是/Users/muaxiu/.jupyter

控制台输入:jupyter notebook --generate-config

c.NotebookApp.browser = u'chrome'

c.NotebookApp.token = ''

c.NotebookApp.password = ''

成功~~~


  jupyter notebook

[W 22:34:15.550 NotebookApp] All authentication is disabled. Anyone who can connect to this server will be able to run code.

[I 22:34:15.566 NotebookApp] Serving notebooks from local directory: /Users/muaxiu

[I 22:34:15.566 NotebookApp] 0 active kernels 

[I 22:34:15.566 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/

[I 22:34:15.567 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).


control+C结束服务



(3)每次进入终端都要source一下,能不能自动开启呢?

When a "login shell" starts up, it reads the file "/etc/profile" and then "~/.bash_profile" or "~/.bash_login" or "~/.profile" (whichever one exists - it only reads one of these, checking for them in the order mentioned).

When a "non-login shell" starts up, it reads the file "/etc/bashrc" and then the file "~/.bashrc".


/Users/your name目录下

muaxiu@muaxiu:~|  ls -a -l 

可以看到所有文件清单,包括隐藏文件

LZMac默认的是zsh,所以修改~/.bashrc并不会在刚打开终端时自动source,所以在~/.zshrc文件最后加上

source ~/.bashrc

source /etc/profile

重新打开终端,Pythonimport caffe就直接成功了


3、jupyter中出现的问题【先放在这里

代码直接粘贴的徐其华-denny的学习专栏中的

import numpy as np

import matplotlib.pyplot as plt

%matplotlib inline

import caffe

caffe_root='/home/xxx/caffe/'

import os,sys

os.chdir(caffe_root)

sys.path.insert(0,caffe_root+'python')

im = caffe.io.load_image('examples/images/cat.jpg')

print im.shape

plt.imshow(im)

plt.axis('off')


  python /Users/muaxiu/caffe/code/test1.py

(360, 480, 3)

src/tcmalloc.cc:283] Attempt to free invalid pointer 0x7f88907de180

[1]    5634 abort      python /Users/muaxiu/caffe/code/test1.py

运行完出现以上问题

解决方法:改变import caffe位置:

import numpy as np

import caffe

import matplotlib.pyplot as plt

#matplotlib inline

caffe_root='/Users/muaxiu/caffe/'

import os,sys

os.chdir(caffe_root)

sys.path.insert(0,caffe_root+'python')

im = caffe.io.load_image('examples/images/cat.jpg')

print im.shape

plt.imshow(im)

plt.show()

plt.axis('off')

则运行成功,加载出了cat图片



jupyter notebook

在网页单元格中复制上述代码,出现:

Kernel Restarting

The kernel appears to have died. It will restart automatically.


尝试:

1pip uninstall ipython

问题继续

2

还未解决,先放在这里,不用jupyter notebook







原创粉丝点击