https://www.helplib.com/GitHub/article_127427
https://blog.csdn.net/aem666/article/details/69525841
https://blog.csdn.net/u012871045/article/details/78839813
250w图片下,对于给定图片,检索top 1000相似时间约为1s,其基本背景和原理会在下文提到。
参考https://blog.csdn.net/han_xiaoyang/article/details/50856583
基于二进制哈希码的快速图像检索算法
源码下载
https://github.com/kevinlin311tw/caffe-cvprw15
编译
cp Makefile.config.example Makefile.config
根据自己的实际情况,修改Makefile.config的内容,主要修改的几个如下:
如果没有GPU,只打算用CPU进行实验,将# CPU_ONLY := 1前的#号去掉。
如果使用GPU,且有cuDNN加速,将# USE_CUDNN := 1前的#号去掉。
如果使用openBLAS,将BLAS := atlas改成BLAS := open,并添加BLAS_INCLUDE := /usr/include/openblas(Caffe中默认的矩阵运算库为ATLAS,但是OpenBLAS有一些性能优化,因此建议换做OpenBLAS)
本人是在vmware的ubutu18.04虚拟机上,没有办法显卡直通,所以是如下配置:
CPU_ONLY := 1
#BLAS := atlas
BLAS := open
# BLAS_INCLUDE := /path/to/your/blas
# BLAS_LIB := /path/to/your/blas
BLAS_INCLUDE := /usr/include/openblas
# MATLAB_DIR := /usr/local
MATLAB_DIR := /usr/local/MATLAB/R2012a
Adjust Makefile.config and simply run the following commands:
$ make all -j8
$ make test -j8
$ make runtest -j8
$ make matcaffe
$ ./download_model.sh
中间错误的时候可以make clean;再make all -j8
apt install liblapack-dev liblapack3 libopenblas-base libopenblas-dev
编译遇到错误,参考
http://kangqingfei.cn/2016/08/25/Linux-%E5%AE%89%E8%A3%85Caffe/
https://blog.csdn.net/hjxu2016/article/details/70256147
https://blog.csdn.net/moses1994/article/details/83931037
sudo dpkg -i libcudnn7_7.4.1.5-1+cuda10.0_amd64.deb
sudo dpkg -i libcudnn7-dev_7.6.1.34-1+cuda10.1_amd64.deb
sudo dpkg -i libcudnn7-doc_7.6.1.34-1+cuda10.1_amd64.deb
不知道这个跟上边啥区别,搜到的。没有用暂时
wget http://file.ppwwyyxx.com/nvidia/cudnn-10.0-linux-x64-v7.4.2.24.tgz
https://github.com/google/leveldb/releases
本次下载1.15版本
make
cp libleveldb.a libleveldb.so* /usr/local/lib/ -rf
cp -r include/leveldb /usr/local/include/
ldconfig
https://github.com/google/leveldb
vi CMakeLists.txt ,添加-fPIC
se(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Enable strict prototype warnings for C code in clang and gcc.
if(NOT CMAKE_C_FLAGS MATCHES "-Wstrict-prototypes")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wstrict-prototypes -fPIC")
endif(NOT CMAKE_C_FLAGS MATCHES "-Wstrict-prototypes")
# Disable C++ exceptions.
string(REGEX REPLACE "-fexceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fPIC")
# Disable RTTI.
string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
endif(CMAKE_CXX_COMPILER_
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Release .. && cmake --build .
sudo cp build/libleveldb.a /usr/local/lib/
sudo cp -r include/leveldb/ /usr/local/include/
报错on.hpp:5:27: fatal error: gflags/gflags.h: No such file or directory
sudo apt-get install libgflags-dev
apt install libboost-dev
apt-get install libgoogle-glog-dev
apt install liblmdb-dev
apt-get install libblas-dev
apt-get install libhdf5-dev
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
在Makefile文件的第173行,把 hdf5_hl 和hdf5修改为hdf5_serial_hl 和 hdf5_serial,也就是把下面第一行代码改为第二行代码。
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial
https://blog.csdn.net/qq_33144323/article/details/80032861
tar zxvf l_mkl_2019.4.243.tgz
sudo ./install.sh进行安装
下载解压之后,运行install.sh 脚本, 一路默认安装即可。在安装开始的时候需要输入序列号,这个如果你在网站上留了有效邮箱,邮件里面是会发给你序列号,输入即可。
安装之后,默认安装路径为 /opt/intel, 找到 /opt/intel/composer_xe_2013_sp1.0.080/mkl/bin/intel64 (如果你的cup是64位的话, 如果不是选择ia32, 懒得选择,执行bin下面的mklvars.sh 也可以).
https://blog.csdn.net/ray_up/article/details/38683383
在末尾处加入代码:
export PATH=":/opt/intel/bin:$PATH"
export LD_LIBRARY_PATH=$LD_LIBRARY_LIB:/opt/intel/lib/intel64:/opt/intel/mkl/lib/intel64
4: $ source /etc/profile 如果没有报错,则path生效
sudo apt-get install libopencv-dev
报错nvcc fatal : Unsupported gpu architecture 'compute_20'
在Makefile.config文件中根据自己CUDA的版本注释不同的行。
# For CUDA >= 9.0, comment the *_20 and *_21 lines for compatibility.
CUDA_ARCH := #-gencode arch=compute_20,code=sm_20 \
#-gencode arch=compute_20,code=sm_21
https://blog.csdn.net/weixin_37983220/article/details/85341058
报错546: recipe for target '.build_release/examples/siamese/convert_mnist_siamese_data.o' failed
这个 是权限问题,采用以下指令:
sudo su;
make all -j8;
https://blog.csdn.net/cfyzcc/article/details/52981467
下载snappy-1.1.3
./autogen.sh
250 ./configure
251 make
252 make install
https://github.com/google/snappy
mkdir build
cd build && cmake ../ && make
sudo make install
cv::imread(cv::String const&, int)’未定义
- 在 Makefile文件的195 行 LIBRARIES += opencv_core opencv_highgui opencv_imgproc 后面添加:
opencv_imgcodecs opencv_videoio
https://blog.csdn.net/wyk1823376647/article/details/81083474
最后报错
/usr/include/glog/logging.h:627:22: note: no known conversion for argument 2 from ‘std::ifstream’ {aka ‘std::basic_ifstream<char>’} to ‘const google::DummyClassToDefineOperator&’
In file included from /usr/include/c++/8/string:52,
from /usr/include/c++/8/bits/locale_classes.h:40,
from /usr/include/c++/8/bits/ios_base.h:41,
from /usr/include/c++/8/ios:42,
from /usr/include/c++/8/istream:38,
from /usr/include/c++/8/fstream:38,
from examples/siamese/convert_mnist_siamese_data.cpp:8:
/usr/include/c++/8/bits/basic_string.h:6323:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)’
operator<<(basic_ostream<_CharT, _Traits>& __os,
^~~~~~~~
/usr/include/c++/8/bits/basic_string.h:6323:5: note: template argument deduction/substitution failed:
examples/siamese/convert_mnist_siamese_data.cpp:39:50: note: ‘std::ifstream’ {aka ‘std::basic_ifstream<char>’} is not derived from ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’
CHECK(label_file) << "Unable to open file " << label_file;
^~
这个错误是因为代码写错了,修改如下
// CHECK(label_file) << "Unable to open file " << label_file;
CHECK(label_file) << "Unable to open file " << label_filename;
麻蛋,这个错误最坑爹,折腾了一天,开始以为是c++库的问题,让我装了c++-6 , c++-7, c++-8这3个库都不行。实在没办法,就注释掉这句话了,编译通过。再仔细看代码,上边的
CHECK(image_file) << "Unable to open file " << image_filename;
没有报错,仔细一看才发现是代码写错了,坑爹,麻蛋。编译都不通过,就把代码提交了,坑人。
make test -j8
有报错
./include/caffe/test/test_gradient_check_util.hpp:164:31: error: no matching function for call to ‘max(const float&, double)’
vim include/caffe/test/test_gradient_check_util.hpp +164
Dtype scale = std::max(
(float)std::max(fabs(computed_gradient), fabs(estimated_gradient)), (float)1.);
编译通过,麻蛋,还得替他修改代码。连个release版本都没有,坑爹
make runtest -j8
make matcaffe
下载matlab2012a
https://pan.baidu.com/s/1tW3TqjrxEzJItA2Tosjmrg
rsnn
Ubuntu18.04安装破解版Matlab_2012a
https://blog.csdn.net/sun007700/article/details/96321443
2016b安装完,执行报错,所以还是 安装2012a吧。
Ubuntu18.04安装破解版Matlab_2016b(完美安装
https://blog.csdn.net/fengfeng0328/article/details/82990838
Matlab 2014a gcc/g++ 4.7.x, Matlab 2016a gcc/g++ 4.9.x Matlab 2017a gcc/g++ 4.9.x
Ubuntu 15.04 gcc/g++ 4.9.x, Ubuntu 16.04 gcc/g++ 5.4.x
原则上Matlab需要和Ubuntu版本一致。
matlab r2015b修改mex使用的gcc g++版本
https://blog.csdn.net/tumi93/article/details/78926332
http://blog.sciencenet.cn/home.php?mod=space&uid=623402&do=blog&id=710896
在MATLAB命令行执行下列命令,任意选择一个编译器
/download_model.sh 需要下载KevinNet_CIFAR10_48.caffemode可以去百度网盘下载
https://pan.baidu.com/s/1TJ7CfJsxXxreDA0ndEND-A
84ig
cd /home/deyi/code/caffe-cvprw15
sudo /usr/local/MATLAB/R2016b/bin/matlab
运行demo报错
cd matlab/caffe/
cp matcaffe_batch_feat.m matcaffe_init_feat.m read_cell.m ../../