复盘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;故障硬盘应为物理故障…

为什么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 {…

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

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

微信小程序和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;…

Samba服务

####################samba####################1.samba作用提供cifs协议实现共享文件2.安装yum install samba samba-common samba-client -ysystemctl start smb nmbsystemctl enable smb nmb3.添加smb用户smb用户必须是本机用户[rootlocalhost ~]# smbpasswd -a student New…

CodeForces 543D 树形DP Road Improvement

题意&#xff1a; 有一颗树&#xff0c;每条边是好边或者是坏边&#xff0c;对于一个节点为x&#xff0c;如果任意一个点到x的路径上的坏边不超过1条&#xff0c;那么这样的方案是合法的&#xff0c;求所有合法的方案数。 对于n个所有可能的x&#xff0c;输出n个答案。 分析&am…

理解Javascritp中的引用

Author: bugall Wechat: bugallF Email: 769088641qq.com Github: https://github.com/bugall一&#xff1a; 函数中的引用传递 我们看下下面的代码的正确输出是什么 function changeStuff(a, b, c) {a a * 10;b.item "changed";c {item: "changed"}; …

ONOS系统架构演进,实现高可用性解决方案

上一篇文章《ONOS高可用性和可扩展性实现初探》讲到了ONOS系统架构在高可用、可扩展方面技术概况&#xff0c;提到了系统在分布式集群中怎样保证数据的一致性。在数据终于一致性方面&#xff0c;ONOS採用了Gossip协议。这一部分的变化不大&#xff0c;而在强一致性方案的选择方…

Struts2_day01

Java Web开发常用框架 SSH(Struts2 Spring Hibernate)SSM(Struts2 Spring MyBatis)SSI(Struts2 Spring iBatis) 多种框架协同工作 Web层 -- Service层 -- Dao层 Struts2框架: Struts2是一个基于MVC设计模式的Web应用框架&#xff0c;它本质上相当于一个servlet&#xff0c;在MV…

使用 python 开发 Web Service

使用 python 开发 Web Service Python 是一种强大的面向对象脚本语言&#xff0c;用 python 开发应用程序往往十分快捷&#xff0c;非常适用于开发时间要求苛刻的原型产品。使用 python 开发 web service 同样有语言本身的简捷高速的特点&#xff0c;能使您快速地提供新的网络服…

java 基础5

一、 什么是数组及其作用&#xff1f; 定义&#xff1a;具有相同数据类型的一个集合 作用&#xff1a;存储连续的具有相同类型的数据 二、 java中如何声明和定义数组 2.1 声明和定义的语法&#xff1a; 数据类型[ ] 数组名&#xff1b;( int[ ] nums ; ) 或 数…

TFS(Team Foundation Server)介绍和入门

在本文的两个部分中&#xff0c;我将介绍Team Foundation Server的一些核心特征&#xff0c;重点介绍在本产品的日常应用中是怎样将这些特性结合在一起使用的。 作为一名软件开发者&#xff0c;在我的职业生涯中&#xff0c;我常常会用到支持软件开发过程的大量开发工具&#x…

[Hadoop] - 自定义Mapreduce InputFormatOutputFormat

在MR程序的开发过程中&#xff0c;经常会遇到输入数据不是HDFS或者数据输出目的地不是HDFS的&#xff0c;MapReduce的设计已经考虑到这种情况&#xff0c;它为我们提供了两个组建&#xff0c;只需要我们自定义适合的InputFormat和OutputFormat&#xff0c;就可以完成这个需求&a…

PS 色调——老照片效果

这就是通过调色使照片显得发黄。 R_new0.393*R0.769*G0.189*B; G_new0.349*R0.686*G0.168*B; B_new0.272*R0.534*G0.131*B; clc; clear all; Imageimread(9.jpg); Imagedouble(Image); Image_newImage; Image_new(:,:,1)0.393*Image(:,:,1)0.769*Image(:,:,2)0.189*Image(:,:,3…

jsp出现错误

昨天在调试页面时发生了如图显示的异常&#xff0c;它出现的原因是当<jsp:forward>或<jsp:include>标签没有参数时&#xff0c;开始标签和结束标签</jsp:forward>或</jsp:include>之间不能有空格&#xff0c;不能换行。解决办法&#xff1a;删除标签之…