復盤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.pswp.cn/news/258487.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/258487.shtml
英文地址,請注明出處:http://en.pswp.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做入參碰到的幾…