Mac 10.14.3+Ubuntu 安装Caffe

Ubuntu16.04 安装caffe CPU-only

问题1:
https://www.cnblogs.com/zjutzz/p/5716453.html?utm_source=itdadao&utm_medium=referral

问题2:
ubuntu 16.04+Caffe:build_release/lib/libcaffe.so:对‘google::protobuf:
已解决(thanks a lot)
https://blog.csdn.net/chenshuibiao/article/details/78734957
图片: https://uploader.shimo.im/f/OB3Lt9OzljUJy0CT.png
error while loading shared libraries: libjpeg.so.62: cannot open shared object file: No such file or directory
https://www.cnblogs.com/zhaoyu1995/p/6305908.html

重新安装了一遍

sudo apt-get install libhdf5-serial-dev

make all 报错

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

https://github.com/esnme/ultrajson/issues/332
图片: https://uploader.shimo.im/f/TR2EeHp6WlYua5ac.png

export DYLD_FALLBACK_LIBRARY_PATH=/anaconda2/envs/py27/lib:/usr/local/lib:~/caffe/.build_release/tools/caffe:~/caffe/.build_release/test/test_all.testbin

注释掉,否则make 会报错!!

加回export DYLD_FALLBACK_LIBRARY_PATH=/anaconda2/envs/py27/lib:
图片: https://uploader.shimo.im/f/3xdODNVfncg6aOGs.png
图片: https://uploader.shimo.im/f/RzueEdunfDYHc31p.png
幸福来得猝不及防!!!
图片: https://uploader.shimo.im/f/mRY5XXz5JVwV8OOw.png

图片: https://uploader.shimo.im/f/MFgvMxxCEdsVBj0h.png

CAFFE
小目标:在Mac上跑通caffe(CPU-only)
完成情况:✅
主要教程:
https://zhuanlan.zhihu.com/p/46930024
https://www.jianshu.com/p/cc16e2977e27
在 macOS 10.13 上编译 py-faster-rcnn
https://aneureka.github.io/2018/12/12/build-py-faster-rcnn-on-macos/
macOS 10.13 安装 caffe 避坑攻略
https://aneureka.github.io/2018/12/12/caffe-install-on-macos/
SolveLog_py27
The Jupyter HTML Notebook. 这将启动一个基于tornado的HTML笔记本 。
tornado不支持python 2.7.3!!

ANACONDA_HOME := /anaconda2/envs/py27/ PYTHON_INCLUDE :=
$(ANACONDA_HOME)/include
$(ANACONDA_HOME)/include/python2.7
$(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include
PYTHON_LIB := $(ANACONDA_HOME)/lib

在这里插入图片描述

在这里插入图片描述
DYLD是一个临时使用的lib库,用完以后就可以改掉!

2019年3月13日
在这里插入图片描述
在这里插入图片描述

强制删除conda的安装包显示json

(1)首先find anaconda3/ -name 包
(2)重点删除: rm -rf /anaconda2/conda-meta/包名.json(关联是否conda list 有显示)

make 和clang的路径选择问题

sudo xcode-select -switch /
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/
#正确选择才能编译(make clang)

ShortCut
查看本机xcode版本

#这条指令执行完要改回去!!

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/
xcodebuild -version 
localhost:~ huxueyan$ xcodebuild -version
Xcode 9.4.1
Build version 9F2000

在这里插入图片描述

确定当前环境site-packages的目录

import site
site.getsitepackages()

修改环境变量

sudo vi ~/.bash_profile
source ~/.bash_profile  
import sys
sys.path
import torch
print(torch.__version__)
/anaconda2/lib/python2.7/site-packages
/usr/local/lib/python2.7/site-packages
brew
which protoc 
rm /usr/local/bin/protoc
which python
brew --prefix openblas
brew --prefix boost
brew --cache
brew link --overwrite boost-python@1.59 --force
conda
conda env remove -n py35
conda env list
conda create -n py36 python=3.6
conda remove -n myenv scipy
conda uninstall scip
SolveLog_base

问题 ImportError: cannot import name descriptor_pb2
解决方案:重新编译protobuf以后生成descriptor_pb2
在这里插入图片描述

问题 ImportError: No module named google.protobuf.internal
解决方案:加入环境变量PYTHONPATH
在这里插入图片描述

问题 显示无法import scikit-image

pip install scikit-image

问题

Library not loaded ImportError:
dlopen(/Users/huxueyan/python/caffe/_caffe.so, 2): Library not loaded:
@rpath/libcaffe.so.1.0.0 Referenced from:
/Users/huxueyan/python/caffe/_caffe.so Reason: image not found

.build_release/tools/caffe dyld: Library not loaded:
@rpath/libhdf5_hl.10.dylib Referenced from:
/Users/work/gitclone/caffe/.build_release/tools/caffe Reason: image
not found make: *** [runtest] Abort trap: 6

解决方案:把相关地址全部加入 DYLD_FALLBACK_LIBRARY
在这里插入图片描述
参考链接:https://www.cnblogs.com/mlj318/p/6478247.html
在这里插入图片描述

问题 no module named caffe
好了,好多教程到这里就没了,然后你会发现。。。咦。。。明明装了caffe。。为什么还是No module named caffe 这个其实是caffe没加到Python路径上的问题
参考链接:https://www.jianshu.com/p/cc16e2977e27

问题 如何使用locate指令?
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
并没有生效。需要执行
sudo /usr/libexec/locate.updatedb
进行库更新。

问题 source ~/.bash_profile 没有立即生效
在这里插入图片描述

source以后最好重开一个终端,设置有延迟。
在这里插入图片描述

问题 fatal error: ‘pyconfig.h’ file not found

在这里插入图片描述
过locate /pyconfig.h发现有多处python环境。有两个注意点:
1、我的anaconda安装在root目录,而非$HOME 目录
2、取消注释的时候,只取消了第一个注释。导致
#/anaconda2/include/python2.7导致/anaconda2/include/python2.7/pyconfig.h找不到。

问题
fatal error: ‘glog/logging.h’ file not found
#include <glog/logging.h> In file included from /usr/local/include/boost/thread.hpp:13:

在这里插入图片描述
解决方案:brew install以后还需要brew link XX --force

问题 fatal error: ‘boost/thread.hpp’ file not found

brew link boost@1.59 --force 
brew link boost-python@1.59 --force

解决方案:brew uninstall boost删除了系统自带的boost,然后重新brew link,问题就解决了。link可以把keg-only的软件变成默认的!

问题
.build_release/src/caffe/proto/caffe.pb.h:17:2: error: #error This
file was generated by an older version of protoc which is
#error This file was generated by an older version of protoc 如果提示权限不够,增加sudo! OSError: [Errno 13] Permission denied:
‘/anaconda2/lib/python2.7/site-packages/protobuf-3.6.1.dist-info/RECORD’
localhost:caffe huxueyan$ sudo pip uninstall protobuf conda remove
和conda uninstall的区别?Alias别名

解决方案:强制卸载pip安装的protobuf3.6.1以后,与手动安装的额protobuf3.5.1不再冲突,编译通过。
参考链接:https://github.com/BVLC/caffe/issues/5645

问题
remote: Counting objects: 66352, done. remote: Compressing objects:
100% (10417/10417), done. error: RPC failed; curl 18 transfer closed
with outstanding read data remaining fatal: The remote end hung up
unexpectedly fatal: early EOF fatal: index-pack failed

git config --global http.postBuffer 524288000
#$ git clone /github_com/large-repository --depth 1
#$ cd large-repository
#$ git fetch --unshallow

解决方案:的确是因为Buffer大小不够,而非网络连接问题。
无效参考:https://stackoverflow.com/questions/38618885/error-rpc-failed-curl-transfer-closed-with-outstanding-read-data-remaining

问题 CondaHTTPError: HTTP 000 CONNECTION FAILED for url

<https://repo.anaconda.com/pkgs/main/osx-64/mkl-2019.1-144.tar.bz2
Elapsed: -

解决方案:conda的offline离线安装

conda install --offline /Users/huxueyan/Downloads/mkl-2019.1-144.tar.bz2

参考链接:https://stackoverflow.com/questions/34316951/install-anaconda-library-from-a-local-source

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值