复盘caffe安装

最近因之前的服务器上的caffe奔溃了,不得已重新安装这一古老的深度学习框架,之前也尝试了好几次,每次都失败,这次总算是成功了,因此及时地总结一下。

以下安装的caffe主要是针对之前虹膜分割和巩膜分割所需的caffe版本。之前已经出过一个安装指南,部分内容与之重叠。

其实整个caffe安装最困难的部分就是各个依赖软件的安装,因此我们只要把这部分安装好了就可以了。

注意:安装指南,请参考《深度学习:21天实战caffe》的第5天那一章,只要按照上面所说的,将所有依赖文件安装在一个目录下,即可。最后安装好的列表应该为:

最后,修改caffe目录下的Makefile.config,找到如下几行:

# Whatever else you find you need goes here.
INCLUDE_DIRS :=/home/caiyong.wang/bin/caffe_local_install/include  $(PYTHON_INCLUDE)    /usr/local/include   
LIBRARY_DIRS :=/home/caiyong.wang/bin/caffe_local_install/lib  $(PYTHON_LIB)   /usr/local/lib /usr/lib  

完整的Makefile.config参考:

## Refer to http://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving our build system are welcome!# cuDNN acceleration switch (uncomment to build with cuDNN).USE_CUDNN := 1# CPU-only switch (uncomment to build without GPU support).
# CPU_ONLY := 1# uncomment to disable IO dependencies and corresponding data layersUSE_OPENCV := 1
# USE_LEVELDB := 0
# USE_LMDB := 0# uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)
#	You should not set this flag if you will be reading LMDBs with any
#	possibility of simultaneous read and write
# ALLOW_LMDB_NOLOCK := 1# Uncomment if you're using OpenCV 3OPENCV_VERSION := 2# To customize your choice of compiler, uncomment and set the following.
# N.B. the default for Linux is g++ and the default for OSX is clang++
# CUSTOM_CXX := g++# CUDA directory contains bin/ and lib/ directories that we need.
CUDA_DIR := /usr/local/cuda
# On Ubuntu 14.04, if cuda tools are installed via
# "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
# CUDA_DIR := /usr# CUDA architecture setting: going with all of them.
# For CUDA < 6.0, comment the *_50 through *_61 lines for compatibility.
# For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility.
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \-gencode arch=compute_20,code=sm_21 \-gencode arch=compute_30,code=sm_30 \-gencode arch=compute_35,code=sm_35 \-gencode arch=compute_50,code=sm_50 \-gencode arch=compute_52,code=sm_52 \-gencode arch=compute_60,code=sm_60 \-gencode arch=compute_61,code=sm_61 \-gencode arch=compute_61,code=compute_61# BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
BLAS := open
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
BLAS_INCLUDE := /opt/OpenBLAS/include
BLAS_LIB := /opt/OpenBLAS/lib# Homebrew puts openblas in a directory that is not on the standard search path
# BLAS_INCLUDE := $(shell brew --prefix openblas)/include
# BLAS_LIB := $(shell brew --prefix openblas)/lib# This is required only if you will compile the matlab interface.
# MATLAB directory should contain the mex binary in /bin.
# MATLAB_DIR :=  /usr/local/MATLAB/R2015a/ 
# MATLAB_DIR := /Applications/MATLAB_R2012b.app# 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
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location, sometimes it's in root.ANACONDA_HOME := $(HOME)/anaconda2PYTHON_INCLUDE := $(ANACONDA_HOME)/include \$(ANACONDA_HOME)/include/python2.7 \$(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include# Uncomment to use Python 3 (default is Python 2)
# PYTHON_LIBRARIES := boost_python3 python3.5m
# PYTHON_INCLUDE := /usr/include/python3.5m \
#                 /usr/lib/python3.5/dist-packages/numpy/core/include# We need to be able to find libpythonX.X.so or .dylib.
# PYTHON_LIB := /usr/libPYTHON_LIB := $(ANACONDA_HOME)/lib# Homebrew installs numpy in a non standard path (keg only)
# PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include
# PYTHON_LIB += $(shell brew --prefix numpy)/lib# Uncomment to support layers written in Python (will link against Python libs)WITH_PYTHON_LAYER := 1# Whatever else you find you need goes here.
INCLUDE_DIRS :=/home/caiyong.wang/bin/caffe_local_install/include  $(PYTHON_INCLUDE)    /usr/local/include   
LIBRARY_DIRS :=/home/caiyong.wang/bin/caffe_local_install/lib  $(PYTHON_LIB)   /usr/local/lib /usr/lib   # If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
# INCLUDE_DIRS += $(shell brew --prefix)/include
# LIBRARY_DIRS += $(shell brew --prefix)/lib# NCCL acceleration switch (uncomment to build with NCCL)
# https://github.com/NVIDIA/nccl (last tested version: v1.2.3-1+cuda8.0)
# USE_NCCL := 1# Uncomment to use `pkg-config` to specify OpenCV library paths.
# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
USE_PKG_CONFIG := 1# N.B. both build and distribute dirs are cleared on `make clean`
BUILD_DIR := build
DISTRIBUTE_DIR := distribute# Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
# DEBUG := 1# The ID of the GPU that 'make runtest' will use to run unit tests.
TEST_GPUID := 0# enable pretty build (comment to see full commands)
Q ?= @LINKFLAGS := -Wl,-rpath,$(ANACONDA_HOME)/lib


下面是一些细节:

1. 首先必须安装python2, 推荐直接安装anaconda2, 例如:https://repo.anaconda.com/archive/Anaconda2-5.0.0.1-Linux-x86_64.sh ,并添加路径到PATH环境变量。

2. opencv的安装
对于opencv,需要安装两个版本,一个是python的,一个是系统的。

对于python,可以安装 

pip install opencv-python==4.2.0.34

直接安装pip install opencv-python,可能出现 “ModuleNotFoundError: No module named 'skbuild' #105”,因此推荐降级安装。

参考:https://github.com/openvinotoolkit/dlstreamer_gst/issues/105

对于系统的安装,方法为:

opencv一般安装opencv 2.4.9, 首先下载opencv-2.4.9.zip源码,并解压:

unzip opencv-2.4.9.zip
cd opencv-2.4.9/
mkdir build;
cd build/
cmake ..
ccmake ..

这里要用到cmake与ccmake,可以自己安装,参考: https://www.24kplus.com/linux/557.html

https://www.cnblogs.com/tosser/p/9905597.html

https://blog.csdn.net/sheqianweilong/article/details/102582668

注意编译过程中需要加入: 

./bootstrap --prefix=/usr --datadir=share/cmake --docdir=doc/cmake --qt-gui && make // 参数--qt-gui是安装cmake-gui,不想安装可以省略

 继续回到opencv的安装,注意在caffe中仅仅使用图像读取和缩放等在CPU上的简单模块,因此可以禁用大部分无关模块以节省编译时间。

然后进行编译安装,

make && make install

至此安装成功。安装成功后,可以将opencv涉及到的bin,lib,pkgconfig填到~/.bashrc,

export PATH=/home/caiyong.wang/bin/caffe_local_install/bin:$PATH
export LD_LIBRARY_PATH=/home/caiyong.wang/bin/caffe_local_install/lib/:$LD_LIBRARY_PATHexport PKG_CONFIG_PATH=/home/caiyong.wang/bin/caffe_local_install/lib/pkgconfig/:$PKG_CONFIG_PATH

然后source ~/.bashrc刷新。

opencv安装成功后,可以运行以下的程序进行测试,测试通过后,证明opencv安装成功,可以顺利安装caffe.

先编辑一个main函数,命名为main.cpp:

#include <stdio.h>  
#include <opencv2/opencv.hpp>
using namespace cv;
int main(void)  
{  printf("%s\r\n", CV_VERSION);  printf("%u.%u.%u\r\n", CV_MAJOR_VERSION, CV_MINOR_VERSION, CV_SUBMINOR_VERSION);  
}  

然后执行:

 g++ -o main main.cpp `pkg-config opencv --cflags --libs`

最后执行: ./main 

PS:对于pkgconfig的一些用法,如下:

[caiyong.wang@omnisky opencv_test]$ pkg-config --cflags opencv
-I/home/caiyong.wang/bin/caffe_local_install/include/opencv -I/home/caiyong.wang/bin/caffe_local_install/include
[caiyong.wang@omnisky opencv_test]$ pkg-config --libs opencv
/home/caiyong.wang/bin/caffe_local_install/lib/libopencv_calib3d.so /home/caiyong.wang/bin/caffe_local_install/lib/libopencv_core.so /home/caiyong.wang/bin/caffe_local_install/lib/libopencv_features2d.so /home/caiyong.wang/bin/caffe_local_install/lib/libopencv_flann.so /home/caiyong.wang/bin/caffe_local_install/lib/libopencv_highgui.so /home/caiyong.wang/bin/caffe_local_install/lib/libopencv_imgproc.so /home/caiyong.wang/bin/caffe_local_install/lib/libopencv_ml.so /home/caiyong.wang/bin/caffe_local_install/lib/libopencv_objdetect.so /home/caiyong.wang/bin/caffe_local_install/lib/libopencv_photo.so /home/caiyong.wang/bin/caffe_local_install/lib/libopencv_stitching.so /home/caiyong.wang/bin/caffe_local_install/lib/libopencv_ts.a -lrt -lpthread -lm -ldl

 

3. protobuf的安装

同上,也必须安装两个版本,一个是python,一个是系统。

python安装: 直接pip install protobuf或者conda install protobuf。

系统安装:参考:https://wangcaiyong.blog.csdn.net/article/details/78283336

参考:https://blog.csdn.net/dgyuanshaofeng/article/details/78151510

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/258487.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

HP P2000 RAID-5两块盘离线的数据恢复报告

1. 故障描述本案例是HP P2000的存储vmware exsi虚拟化平台&#xff0c;由RAID-5由10块lT硬盘组成&#xff0c;其中6号盘是热备盘&#xff0c;由于故障导致RAID-5磁盘阵列的两块盘掉线&#xff0c;表现为两块硬盘亮黄灯。 经用户方维护人员检测&#xff0c;故障硬盘应为物理故障…

微智魔盒骗局_微智魔盒官宣

原标题&#xff1a;微智魔盒官宣微智魔盒官方宣传视频微达国际集团创建于2011年&#xff0c;是一家坚持创新的集科研、产销、服务为一体的智能化产业平台&#xff0c;致力于国际领先的专注人工智能领域的产业投资、项目孵化、教育培训&#xff0c;并提供终极解决方案。集团创新…

瑞柏匡丞_移动互联的发展现状与未来

互联网作为人类文明史上最伟大、最重要的科技发明之一&#xff0c;发展到今天&#xff0c;用翻天覆地来形容并不过分。而作为传统互联网的延伸和演进方向&#xff0c;移动互联网更是在近两年得到了迅猛的发展。如今&#xff0c;越来越多的用户得以通过高速的移动网络和强大的智…

android 进程间通信数据(一)------parcel的起源

关于parcel&#xff0c;我们先来讲讲它的“父辈” Serialize。 Serialize 是java提供的一套序列化机制。但是为什么要序列化&#xff0c;怎么序列化&#xff0c;序列化是怎么做到的&#xff0c;我们将在本文探讨下。 一&#xff1a;java 中的serialize 关于Serialize这个东东&a…

为什么torch.nn.Linear的表达形式为y=xA^T+b而不是常见的y=Ax+b?

今天看代码&#xff0c;对比了常见的公式表达与代码的表达&#xff0c;发觉torch.nn.Linear的数学表达与我想象的有点不同&#xff0c;于是思索了一番。 众多周知&#xff0c;torch.nn.Linear作为全连接层&#xff0c;将下一层的每个结点与上一层的每一节点相连&#xff0c;用…

Leetcode47: Palindrome Linked List

Given a singly linked list, determine if it is a palindrome. 推断一个链表是不是回文的&#xff0c;一个比較简单的办法是把链表每一个结点的值存在vector里。然后首尾比較。时间复杂度O(n)。空间复杂度O(n)。 /*** Definition for singly-linked list.* struct ListNode {…

内存颗粒位宽和容量_SDRAM的逻辑Bank与芯片容量表示方法

1、逻辑Bank与芯片位宽讲完SDRAM的外在形式&#xff0c;就该深入了解SDRAM的内部结构了。这里主要的概念就是逻辑Bank。简单地说&#xff0c;SDRAM的内部是一个存储阵列。因为如果是管道式存储(就如排队买票)&#xff0c;就很难做到随机访问了。阵列就如同表格一样&#xff0c;…

[Unity菜鸟] Time

1. Time.deltaTime 增量时间 以秒计算&#xff0c;完成最后一帧的时间(秒)(只读) 帧数所用的时间不是你能控制的。每一帧都不一样&#xff0c;游戏一般都是每秒60帧&#xff0c;也就是updata方法调用60次&#xff08;假如你按60帧来算 而真实情况是不到60帧 那么物体就不会运动…

【转】七个例子帮你更好地理解 CPU 缓存

我的大多数读者都知道缓存是一种快速、小型、存储最近已访问的内存的地方。这个描述相当准确&#xff0c;但是深入处理器缓存如何工作的“枯燥”细节&#xff0c;会对尝试理解程序性能有很大帮助。在这篇博文中&#xff0c;我将通过示例代码来说明缓存是如何工作的&#xff0c;…

Pytorch——对应点相乘和矩阵相乘

1. 点乘&#xff0c;对应元素相乘&#xff0c;不求和 import torcha torch.Tensor([[1,2], [3,4], [5,6]]) b1 a.mul(a)// b2a*a b1 Out[79]: tensor([[ 1., 4.],[ 9., 16.],[25., 36.]]) b2 Out[80]: tensor([[ 1., 4.],[ 9., 16.],[25., 36.]]) 以上两种方法都可以表…

mysql初始化错误【一】Can't find error-message file '/usr/local/mysql/errmsg.sys'

环境&#xff1a;CentOS 7.2MySQL 5.7.18从mysql官方网站下载rpm包到服务器本地&#xff0c;依次安装下面的RPM包&#xff1a;mysql-community-common-5.7.18-1.el7.x86_64.rpmmysql-community-server-5.7.18-1.el7.x86_64.rpmmysql-community-client-5.7.18-1.el7.x86_64.rpmm…

双极型adc与stm32_关于STM32 双ADC同步规则转换两路数据的问题?

因系统要求需升级ADC的采样方式(以前方式&#xff1a;扫描方式&#xff0c;TIMER2触发ADC软启动&#xff0c;2通道规则序列&#xff0c;DMA传完中断)&#xff0c;为了进一步实现两路信号的同步性能&#xff0c;采样STM32 双ADC同步规则转换。(timer2触发ADC软启动&#xff0c;2…

面试金典--11.5

题目描述&#xff1a;给定排序后的字符串数组&#xff0c;中间有一些空串&#xff0c;要求找到给定字符串的位置 思路&#xff1a; &#xff08;1&#xff09;遍历&#xff0c;最慢的 &#xff08;2&#xff09;二分查找&#xff0c;当mid处为空串&#xff0c;就找到最近的非空…

win10 平台VS2019最简安装实现C++/C开发

这两天一直在安装vs2015,总是卡在visual studio 2015 出现安装包丢失或损坏的现象&#xff0c;尽管按照网上很多方法尝试解决&#xff0c;但是一直不行。算了。还是使用最新版的VS 2019安装&#xff0c;没想到很顺利。 下面总结一下在win10平台上最简安装VS2019&#xff0c;实…

Hook的两个小插曲

看完了前面三篇文章后&#xff0c;这里我们来一个小插曲~~~~ 第一个小插曲。是前面文章一个CM精灵的分析。我们这里使用hook代码来搞定。 第二个小插曲&#xff0c;是如今一些游戏&#xff0c;都有了支付上限&#xff0c;比如每天仅仅能花20块钱来购买。好了。以下我们分开叙述…

### C++总结-[类成员函数]

C类中的常见函数。 #author: gr #date: 2015-07-23 #email: forgeruigmail.com 一、constructor, copy constructor, copy assignment, destructor 1. copy constructor必须传引用&#xff0c;传值编译器会报错 2. operator 返回值为引用&#xff0c;为了…

微信小程序和vue双向绑定哪里不一样_个人理解Vue和React区别

本文转载自掘金&#xff0c;作者&#xff1a;binbinsilk&#xff0c;监听数据变化的实现原理不同Vue 通过 getter/setter 以及一些函数的劫持&#xff0c;能精确知道数据变化&#xff0c;不需要特别的优化就能达到很好的性能React 默认是通过比较引用的方式进行的&#xff0c;如…

JS 省,市,区

1 // 纯JS省市区三级联动2 // 2011-11-30 by http://www.cnblogs.com/zjfree3 var addressInit function (_cmbProvince, _cmbCity, _cmbArea, defaultProvince, defaultCity, defaultArea) {4 var cmbProvince document.getElementById(_cmbProvince);5 var cmbCity…

使用极链/AutoDL云服务器复盘caffe安装

继上一次倒腾caffe安装以后&#xff0c;因为博士毕业等原因&#xff0c;旧的服务器已经不能再使用&#xff0c;最近因论文等原因&#xff0c;不得不继续来安装一下我的caffe。这次运气比较好&#xff0c;经历了一晚上和一早上的痛苦之后&#xff0c;最终安装成功了&#xff0c;…

ibatis中使用List作为传入参数的使用方法及 CDATA使用

ibatis中list做回参很简单&#xff0c;resultClass设为list中元素类型&#xff0c;dao层调用: (List)getSqlMapClientTemplate().queryForList("sqlName", paraName); 并经类型转换即可&#xff0c;做入参还需要稍微调整下&#xff0c;本文主要讲list做入参碰到的几…