zoukankan      html  css  js  c++  java
  • 深度学习框架caffe在macOS Heigh Sierra上安装过程实录

    第一步、安装依赖库

    brew install -vd snappy leveldb gflags glog szip lmdb
    brew tap homebrew/science
    brew install hdf5 opencv
    brew install protobuf boost

    第二步、编译caffe

    git clone https://github.com/BVLC/caffe.git
    cd caffe
    make all && make test && make runtest

    问题一:

    in file included from src/caffe/common.cpp:7:
    In file included from ./include/caffe/common.hpp:19:
    ./include/caffe/util/device_alternate.hpp:34:10: fatal error: 'cublas_v2.h' file not found
    #include <cublas_v2.h>
    ^~~~~~~~~~~~~
    1 error generated.

    解决方案:
    设置Makefile.config中取消注释CPU_ONLY := 1前面的注释

    问题二:

    ./include/caffe/util/mkl_alternate.hpp:14:10: fatal error: 'cblas.h' file not found
    #include <cblas.h>

    解决方案:
    第1步:brew install homebrew/science/openblas
    第2步:
    修改Makefile.config文件中BLAS:= atlas为BLAS := OpenBlas
    修改Makefile.config文件中BLAS的库或头文件:
    BLAS_INCLUDE := /usr/local/opt/openblas/include
    BLAS_LIB := /usr/local/opt/openblas/lib

    问题三:

    No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.
    /bin/sh: line 0: [: -gt: unary operator expected
    /bin/sh: line 0: [: -gt: unary operator expected
    LD -o .build_release/lib/libcaffe.so.1.0.0
    clang: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]
    ld: framework not found vecLib
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [.build_release/lib/libcaffe.so.1.0.0] Error 1

    解决方案:
    在命令行中输入:xcode-select --install

    第三步、编译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

    解决方案:
    第1步:brew install numpy
    第2步:

    修改Makefile.config

    去掉注释

    # PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include
    # PYTHON_LIB += $(shell brew --prefix numpy)/lib

    变为

    PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include
    PYTHON_LIB += $(shell brew --prefix numpy)/lib

    问题二:

    ld: library not found for -lboost_python
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [python/caffe/_caffe.so] Error 1

    解决方案:
    brew install boost-python

    安装caffe的python依赖:
    cd python
    for req in $(cat requirements.txt); do pip install --user $req; done

  • 相关阅读:
    Ninject之旅之十四:Ninject在ASP.NET Web Form程序上的应用(附程序下载)
    Ninject之旅之十三:Ninject在ASP.NET MVC程序上的应用(附程序下载)
    Ninject之旅之十二:Ninject在Windows Form程序上的应用(附程序下载)
    Ninject之旅之十一:Ninject动态工厂(附程序下载)
    Ninject之旅之十:Ninject自定义提供者
    Ninject之旅之九:Ninject上下文绑定(附程序下载)
    Ninject之旅之八:Ninject插件模型(附程序下载)
    linq语句的顺序查询,查询结果不同
    layui 的使用 table 和后端数据交互
    获取post的参数
  • 原文地址:https://www.cnblogs.com/springwind2006/p/7635860.html
Copyright © 2011-2022 走看看