源码地址:
https://github.com/chengyangfu/caffe/tree/dssd
1.down源码
git clone https://github.com/chengyangfu/caffe.git
cd $CAFFE_ROOT
git checkout dssd
2.编译
# Modify Makefile.config according to your Caffe installation.
cp Makefile.config.example Makefile.config
make -j8
# Make sure to include $CAFFE_ROOT/python to your PYTHONPATH.
make py
make test -j8
# (Optional)
make runtest -j
错误:make -j8
PROTOC src/caffe/proto/caffe.proto
NVCC src/caffe/layers/base_data_layer.cu
NVCC src/caffe/layers/absval_layer.cu
NVCC src/caffe/layers/batch_norm_layer.cu
NVCC src/caffe/layers/batch_reindex_layer.cu
NVCC src/caffe/layers/bias_layer.cu
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
NVCC src/caffe/layers/bnll_layer.cu
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
NVCC src/caffe/layers/concat_layer.cu
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
NVCC src/caffe/layers/contrastive_loss_layer.cu
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
./include/caffe/util/cudnn.hpp(112): error: too few arguments in function call
1 error detected in the compilation of "/tmp/tmpxft_00004b78_00000000-5_absval_layer.cpp4.ii".
Makefile:607: recipe for target '.build_release/cuda/src/caffe/layers/absval_layer.o' failed
make: *** [.build_release/cuda/src/caffe/layers/absval_layer.o] Error 1
make: *** Waiting for unfinished jobs....
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
./include/caffe/util/cudnn.hpp(112): error: too few arguments in function call
1 error detected in the compilation of "/tmp/tmpxft_00004b7f_00000000-5_bias_layer.cpp4.ii".
Makefile:607: recipe for target '.build_release/cuda/src/caffe/layers/bias_layer.o' failed
make: *** [.build_release/cuda/src/caffe/layers/bias_layer.o] Error 1
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
./include/caffe/util/cudnn.hpp(112): error: too few arguments in function call
1 error detected in the compilation of "/tmp/tmpxft_00004b91_00000000-5_batch_norm_layer.cpp4.ii".
Makefile:607: recipe for target '.build_release/cuda/src/caffe/layers/batch_norm_layer.o' failed
make: *** [.build_release/cuda/src/caffe/layers/batch_norm_layer.o] Error 1
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
./include/caffe/util/cudnn.hpp(112): error: too few arguments in function call
1 error detected in the compilation of "/tmp/tmpxft_00004b90_00000000-5_contrastive_loss_layer.cpp4.ii".
Makefile:607: recipe for target '.build_release/cuda/src/caffe/layers/contrastive_loss_layer.o' failed
make: *** [.build_release/cuda/src/caffe/layers/contrastive_loss_layer.o] Error 1
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
./include/caffe/util/cudnn.hpp(112): error: too few arguments in function call
1 error detected in the compilation of "/tmp/tmpxft_00004b71_00000000-5_batch_reindex_layer.cpp4.ii".
Makefile:607: recipe for target '.build_release/cuda/src/caffe/layers/batch_reindex_layer.o' failed
make: *** [.build_release/cuda/src/caffe/layers/batch_reindex_layer.o] Error 1
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
./include/caffe/util/cudnn.hpp(112): error: too few arguments in function call
1 error detected in the compilation of "/tmp/tmpxft_00004b92_00000000-5_concat_layer.cpp4.ii".
Makefile:607: recipe for target '.build_release/cuda/src/caffe/layers/concat_layer.o' failed
make: *** [.build_release/cuda/src/caffe/layers/concat_layer.o] Error 1
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
./include/caffe/util/cudnn.hpp(112): error: too few arguments in function call
1 error detected in the compilation of "/tmp/tmpxft_00004bb7_00000000-5_base_data_layer.cpp4.ii".
Makefile:607: recipe for target '.build_release/cuda/src/caffe/layers/base_data_layer.o' failed
make: *** [.build_release/cuda/src/caffe/layers/base_data_layer.o] Error 1
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
./include/caffe/util/cudnn.hpp(112): error: too few arguments in function call
1 error detected in the compilation of "/tmp/tmpxft_00004b82_00000000-5_bnll_layer.cpp4.ii".
Makefile:607: recipe for target '.build_release/cuda/src/caffe/layers/bnll_layer.o' failed
make: *** [.build_release/cuda/src/caffe/layers/bnll_layer.o] Error 1
解决方法:系统的cudnn和作者的不匹配:
1. 将./include/caffe/util/cudnn.hpp 换成最新版的caffe里的cudnn的实现,即相应的cudnn.hpp.
2. 将./include/caffe/layers里的,所有以cudnn开头的文件,例如cudnn_conv_layer.hpp。 都替换成最新版的caffe里的相应的同名文件。
3.将./src/caffe/layer里的,所有以cudnn开头的文件,例如cudnn_lrn_layer.cu,cudnn_pooling_layer.cpp,cudnn_sigmoid_layer.cu。
2.
CXX/LD -o .build_release/tools/caffe.bin
CXX/LD -o .build_release/tools/upgrade_net_proto_binary.bin
CXX/LD -o .build_release/tools/upgrade_net_proto_text.bin
CXX/LD -o .build_release/tools/extract_features.bin
CXX/LD -o .build_release/tools/compute_image_mean.bin
CXX/LD -o .build_release/tools/upgrade_solver_proto_text.bin
CXX/LD -o .build_release/tools/convert_imageset.bin
CXX/LD -o .build_release/examples/cpp_classification/classification.bin
.build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
collect2: error: ld returned 1 exit status
Makefile:638: recipe for target '.build_release/tools/upgrade_net_proto_text.bin' failed
make: *** [.build_release/tools/upgrade_net_proto_text.bin] Error 1
make: *** Waiting for unfinished jobs....
.build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
collect2: error: ld returned 1 exit status
Makefile:638: recipe for target '.build_release/tools/upgrade_net_proto_binary.bin' failed
make: *** [.build_release/tools/upgrade_net_proto_binary.bin] Error 1
.build_release/examples/cpp_classification/classification.o: In function `main':
classification.cpp:(.text.startup+0x233): undefined reference to `cv::imread(cv::String const&, int)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
collect2: error: ld returned 1 exit status
collect2: error: ld returned 1 exit status
Makefile:638: recipe for target '.build_release/tools/convert_imageset.bin' failed
make: *** [.build_release/tools/convert_imageset.bin] Error 1
Makefile:643: recipe for target '.build_release/examples/cpp_classification/classification.bin' failed
make: *** [.build_release/examples/cpp_classification/classification.bin] Error 1
.build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
collect2: error: ld returned 1 exit status
Makefile:638: recipe for target '.build_release/tools/upgrade_solver_proto_text.bin' failed
make: *** [.build_release/tools/upgrade_solver_proto_text.bin] Error 1
.build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
collect2: error: ld returned 1 exit status
Makefile:638: recipe for target '.build_release/tools/compute_image_mean.bin' failed
make: *** [.build_release/tools/compute_image_mean.bin] Error 1
.build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
collect2: error: ld returned 1 exit status
Makefile:638: recipe for target '.build_release/tools/extract_features.bin' failed
make: *** [.build_release/tools/extract_features.bin] Error 1
.build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
collect2: error: ld returned 1 exit status
Makefile:638: recipe for target '.build_release/tools/caffe.bin' failed
make: *** [.build_release/tools/caffe.bin] Error 1
解决方法:
https://blog.csdn.net/sinat_38011533/article/details/89105341
3.
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0
CXX tools/compute_image_mean.cpp
CXX/LD -o .build_release/tools/compute_image_mean.bin
.build_release/lib/libcaffe.so: undefined reference to `boost::re_detail::cpp_regex_traits_implementation<char>::transform_primary(char const*, char const*) const'
.build_release/lib/libcaffe.so: undefined reference to `boost::re_detail::cpp_regex_traits_implementation<char>::transform(char const*, char const*) const'
.build_release/lib/libcaffe.so: undefined reference to `cv::VideoCapture::set(int, double)'
.build_release/lib/libcaffe.so: undefined reference to `boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >::maybe_assign(boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > > const&)'
.build_release/lib/libcaffe.so: undefined reference to `boost::re_detail::put_mem_block(void*)'
.build_release/lib/libcaffe.so: undefined reference to `cv::VideoWriter::write(cv::Mat const&)'
.build_release/lib/libcaffe.so: undefined reference to `boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
.build_release/lib/libcaffe.so: undefined reference to `boost::re_detail::get_mem_block()'
.build_release/lib/libcaffe.so: undefined reference to `cv::VideoCapture::open(cv::String const&)'
.build_release/lib/libcaffe.so: undefined reference to `cv::VideoCapture::release()'
.build_release/lib/libcaffe.so: undefined reference to `cv::VideoCapture::operator>>(cv::Mat&)'
.build_release/lib/libcaffe.so: undefined reference to `cv::VideoWriter::VideoWriter(cv::String const&, int, double, cv::Size_<int>, bool)'
.build_release/lib/libcaffe.so: undefined reference to `cv::VideoCapture::isOpened() const'
.build_release/lib/libcaffe.so: undefined reference to `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int)'
.build_release/lib/libcaffe.so: undefined reference to `cv::VideoCapture::get(int) const'
.build_release/lib/libcaffe.so: undefined reference to `cv::VideoWriter::VideoWriter()'
.build_release/lib/libcaffe.so: undefined reference to `cv::VideoCapture::open(int)'
.build_release/lib/libcaffe.so: undefined reference to `boost::re_detail::raise_runtime_error(std::runtime_error const&)'
.build_release/lib/libcaffe.so: undefined reference to `boost::cpp_regex_traits<char>::toi(char const*&, char const*, int) const'
.build_release/lib/libcaffe.so: undefined reference to `cv::VideoWriter::isOpened() const'
.build_release/lib/libcaffe.so: undefined reference to `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::construct_init(boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags)'
.build_release/lib/libcaffe.so: undefined reference to `boost::re_detail::verify_options(unsigned int, boost::regex_constants::_match_flags)'
.build_release/lib/libcaffe.so: undefined reference to `cv::VideoWriter::~VideoWriter()'
.build_release/lib/libcaffe.so: undefined reference to `cv::VideoCapture::~VideoCapture()'
.build_release/lib/libcaffe.so: undefined reference to `boost::re_detail::get_default_error_string(boost::regex_constants::error_type)'
.build_release/lib/libcaffe.so: undefined reference to `boost::filesystem::detail::remove_all(boost::filesystem::path const&, boost::system::error_code*)'
.build_release/lib/libcaffe.so: undefined reference to `boost::filesystem::path::operator/=(boost::filesystem::path const&)'
.build_release/lib/libcaffe.so: undefined reference to `cv::VideoCapture::VideoCapture()'
.build_release/lib/libcaffe.so: undefined reference to `boost::filesystem::detail::create_directories(boost::filesystem::path const&, boost::system::error_code*)'
collect2: error: ld returned 1 exit status
Makefile:639: recipe for target '.build_release/tools/compute_image_mean.bin' failed
make: *** [.build_release/tools/compute_image_mean.bin] Error 1
解决方法:
Makefile
修改:
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs
4.
改的实在是烦,把ssd调通的Makefile和Makefile.config换上,一步调通。
https://mp.csdn.net/postedit/88713008