(caffe)python3.6编译libboost_python3.so并编译cpu-caffe

更新时间:2023-05-15 18:16:09 阅读: 评论:0

(caffe)python3.6编译libboost_python3.so并编译cpu-caffe 写这篇主要是使⽤fast-reid中torch转caffe模型,通过run_inference.sh调⽤caffe python3.6接⼝失败,花了太多时间,所以记录以下。这⾥感谢,⼀起讨论fast-reid pytorch转caffe的问题。已在多台设备上编译成功多次。
0.环境
python3.6
numpy
boost_1_68_0
1.下载boost
wget /boostorg/relea/1.68.0/source/boost_1_68_
美语俚语
三人行必有我师翻译2.解压⽂件
tar xzvf boost_1_68_
cd boost_1_68_0/
3.安装附加依赖库
apt-get update粉领
sudo apt-get install git
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev
libhdf5-rial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install libatlas-ba-dev
cocesudo apt-get install python-dev
sudo apt-get insall libgflags-dev libgoogle-glog-dev liblmdb-dev
4.安装boost
sh ./bootstrap.sh --with-libraries=all --with-toolt=gcc
./b2 include="/usr/include/python3.6m/"
可以通过whereis命令来查看python3.6m路径。
./b2 install
5.创建软链接
cd /usr/local/lib
潜行深渊ln -s libboost_python-py36.so libboost_python3.so
ln -s libboost_python-py36.a libboost_python3.a
cp /usr/local/lib/libboost_python36.a  /usr/lib/x86_64-linux-gnu/libboost_python_python36.a cp /usr/local/lib/libboost_python36.so.1.68.0  /usr/lib/x86_64-linux-gnu/libboost_python3.so
将部分依赖的链接复制到/usr/lib/x86_64-linux-gnu/下,就不需要export了。
cp /usr/local/lib/libboost_python36.so.1.68.0 /usr/lib/x86_64-linux-gnu/
cp /usr/local/lib/libboost_system.so.1.68.0 /usr/lib/x86_64-linux-gnu/
cp /usr/local/lib/libboost_filesystem.so.1.68.0 /usr/lib/x86_64-linux-gnu/
个人礼仪培训cp /usr/local/lib/libboost_thread.so.1.68.0 /usr/lib/x86_64-linux-gnu/
6.安装cpu版本caffe
apt-get -y install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-rial-dev protobuf-compiler apt-get -y install --no-install-recommends libboost-all-dev
apt-get -y install libopenblas-dev liblapack-dev libatlas-ba-dev
apt-get -y install libgflags-dev libgoogle-glog-dev liblmdb-dev
apt-get -y install git cmake build-esntial
git clone /BVLC/caffe.git
chmod 777 -R caffe
cd caffe
fig
fig
CPU_ONLY := 1
WITH_PYTHON_LAYER := 1
# Uncomment to u Python 3 (default is Python 2)
PYTHON_LIBRARIES := boost_python3 python3.6m
PYTHON_INCLUDE := /usr/include/python3.6m \
/usr/lib/python3.6/dist-packages/numpy/core/include
vim Makefile
dominate翻译
PYTHON_LIBRARIES := boost_python python2.7
to
licentiousPYTHON_LIBRARIES := boost_python3 python3.6m
(1)caffe-master/include/caffe/layers/pooling_layer.hpp
line 54-55:
bool ceil_mode_;  //添加的类成员变量
// PoolingParameter_RoundMode round_mode_;
make all -j8  #-j8根据⾃⼰电脑配置决定
make test -j8
make runtest -j8 #测试
# export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/boost_1_68_0/lib:$LD_LIBRARY_PATH
(2)caffe-master/src/caffe/layers/pooling_layer.cpp
line 38-39:
ceil_mode_ = il_mode();      //添加的代码,主要作⽤是从参数⽂件中获取ceil_mode_的参数数值。//round_mode_ = und_mode();
line 92-121:
// 添加的代码-----------------------------------
if (ceil_mode_) {
pooled_height_ = static_cast<int>(ceil(static_cast<float>(
height_ + 2 * pad_h_ - kernel_h_) / stride_h_)) + 1;
pooled_width_ = static_cast<int>(ceil(static_cast<float>(
width_ + 2 * pad_w_ - kernel_w_) / stride_w_)) + 1;
} el {
pooled_height_ = static_cast<int>(floor(static_cast<float>(
height_ + 2 * pad_h_ - kernel_h_) / stride_h_)) + 1;
pooled_width_ = static_cast<int>(floor(static_cast<float>(
width_ + 2 * pad_w_ - kernel_w_) / stride_w_)) + 1;
}
// ------------------------------------------------------中英文对照小说
/*switch (round_mode_) {
genki
ca PoolingParameter_RoundMode_CEIL:
pooled_height_ = static_cast<int>(ceil(static_cast<float>(
height_ + 2 * pad_h_ - kernel_h_) / stride_h_)) + 1;
pooled_width_ = static_cast<int>(ceil(static_cast<float>(
width_ + 2 * pad_w_ - kernel_w_) / stride_w_)) + 1;
break;
ca PoolingParameter_RoundMode_FLOOR:
pooled_height_ = static_cast<int>(floor(static_cast<float>(
height_ + 2 * pad_h_ - kernel_h_) / stride_h_)) + 1;
pooled_width_ = static_cast<int>(floor(static_cast<float>(
width_ + 2 * pad_w_ - kernel_w_) / stride_w_)) + 1;
break;
default:
LOG(FATAL) << "Unknown rounding mode.";
}*/
(3)/caffe-master/src/caffe/proto/caffe.proto
optional Engine engine = 11 [default = DEFAULT];
// If global_pooling then it will pool over the size of the bottom by doing
// kernel_h = bottom->height and kernel_w = bottom->width
optional bool global_pooling = 12 [default = fal];
// How to calculate the output size - using ceil (default) or floor rounding.
//enum RoundMode {
/
/  CEIL = 0;
//  FLOOR = 1;
//}
//optional RoundMode round_mode = 13 [default = CEIL];
optional bool ceil_mode = 13 [default = true];
给⼀个最后成功的显⽰:

本文发布于:2023-05-15 18:16:09,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/90/109645.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:参数   依赖   添加   查看   链接
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图