Ubuntu 18.04 + 1.14 Autoware USE CPU&GPU

  • 安装caffe
    • 系统依赖项
    • 获取ssd版caffe
    • 编译前工作
      • Makefile.config
      • Makefile
    • 编译
      • 进入文件 DEFINE CPU_ONLY
      • 可能会遇到的问题
        • /usr/bin/ld: cannot find -lopenblas
        • 更多问题见引用参考
    • 导入模型文件
  • Autoware 适配
    • 修改CMakeLists.txt
    • 链接库
    • 修改launch 虽然界面也能勾选
    • 编译Autoware
  • 运行
    • 运行runtime_manager
      • 播放BAG
    • 运行vision_ssd_detect节点
  • 效果示意
  • GPU版本的修改为:
    • CUDA安装
    • caffe里的Makefile.config
    • 关于Eigen的版本
      • 源码安装法
    • 编译cafffe
      • 报错类型
        • atal error: caffe/caffe.hpp: No such file or directory #include "caffe/caffe.hpp"
        • make test -j8的时候报错
    • 编译Autoware with CUDA

引用参考:

  1. Ubuntu 16.04配置caffe-ssd
    这篇应该说修改指南最全的一个了… 蟹老板之前找了好多都无效,JMK找到的这版,但是运行起autoware的vision_ssd_detect还是需要其他操作,所以前半部分可能就是这篇里的一些操作
    特别鸣谢:蟹老板和JMK的贡献!非常给力 我算是照着他们的流程走 顺便记录了一下而已…

首先写一下为什么不直接:sudo apt install caffe-cpu 因为… 改不了model【或者说我不知道model的路径在哪里,apt install下载下来也没找到 所以就还是采取了源码安装的方法】
感觉写完好长哦… 等自己电脑装的时候再录个屏大家倍速播放就好了…
GPU版请下拉到GPU

安装caffe

系统依赖项

sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev
sudo apt-get install libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install libatlas-base-dev
sudo apt-get install python-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

获取ssd版caffe

说明:SSD采用的是在caffe文件夹中内嵌例程的方式,作者改动了原版caffe,所以你需要把原来的caffe文件夹移除,git命令会新建一个带有SSD程序的caffe文件夹,当然,这个新的caffe要重新编译一次。这里我直接拉取了gitee的链接 下载风驰电掣,原github链接还是点击此处

git clone https://gitee.com/kin_zhang/caffe.git
cd caffe
git checkout ssd

注意一定要切换到ssd分支,如图:

编译前工作

Makefile.config

复制样例并修改Makefile.config文件:

cd caffe
cp Makefile.config.example Makefile.config
gedit Makefile.config

这是修改好后的直接复制替换:【注意注释了CUDA 不使用CPU】

## 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 layers
# USE_OPENCV := 0
# 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 := 3# 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 lines after *_35 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_61,code=sm_61# BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
# BLAS := atlas
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 := /path/to/your/blas
# BLAS_LIB := /path/to/your/blas# 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_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)/anaconda2
# PYTHON_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/lib
# PYTHON_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 := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial# 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# 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 ?= @

具体的修改为

  1. CPU_ONLY := 1
  2. OPENCV_VERSION := 3
  3. 注释 掉了CUDA的东西:
# 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 lines after *_35 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_61,code=sm_61
  1. WITH_PYTHON_LAYER := 1
  2. INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
  3. LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial

Makefile

cd caffe
gedit Makefile

不想自己找的就直接复制全选粘贴:想看改了哪里的请跳过这部分 点击此处后面

PROJECT := caffeCONFIG_FILE := Makefile.config
# Explicitly check for the config file, otherwise make -k will proceed anyway.
ifeq ($(wildcard $(CONFIG_FILE)),)
$(error $(CONFIG_FILE) not found. See $(CONFIG_FILE).example.)
endif
include $(CONFIG_FILE)BUILD_DIR_LINK := $(BUILD_DIR)
ifeq ($(RELEASE_BUILD_DIR),)RELEASE_BUILD_DIR := .$(BUILD_DIR)_release
endif
ifeq ($(DEBUG_BUILD_DIR),)DEBUG_BUILD_DIR := .$(BUILD_DIR)_debug
endifDEBUG ?= 0
ifeq ($(DEBUG), 1)BUILD_DIR := $(DEBUG_BUILD_DIR)OTHER_BUILD_DIR := $(RELEASE_BUILD_DIR)
elseBUILD_DIR := $(RELEASE_BUILD_DIR)OTHER_BUILD_DIR := $(DEBUG_BUILD_DIR)
endif# All of the directories containing code.
SRC_DIRS := $(shell find * -type d -exec bash -c "find {} -maxdepth 1 \\( -name '*.cpp' -o -name '*.proto' \) | grep -q ." \; -print)# The target shared library name
LIBRARY_NAME := $(PROJECT)
LIB_BUILD_DIR := $(BUILD_DIR)/lib
STATIC_NAME := $(LIB_BUILD_DIR)/lib$(LIBRARY_NAME).a
DYNAMIC_VERSION_MAJOR       := 1
DYNAMIC_VERSION_MINOR       := 0
DYNAMIC_VERSION_REVISION    := 0-rc3
DYNAMIC_NAME_SHORT := lib$(LIBRARY_NAME).so
#DYNAMIC_SONAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR)
DYNAMIC_VERSIONED_NAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION)
DYNAMIC_NAME := $(LIB_BUILD_DIR)/$(DYNAMIC_VERSIONED_NAME_SHORT)
COMMON_FLAGS += -DCAFFE_VERSION=$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION)##############################
# Get all source files
##############################
# CXX_SRCS are the source files excluding the test ones.
CXX_SRCS := $(shell find src/$(PROJECT) ! -name "test_*.cpp" -name "*.cpp")
# CU_SRCS are the cuda source files
CU_SRCS := $(shell find src/$(PROJECT) ! -name "test_*.cu" -name "*.cu")
# TEST_SRCS are the test source files
TEST_MAIN_SRC := src/$(PROJECT)/test/test_caffe_main.cpp
TEST_SRCS := $(shell find src/$(PROJECT) -name "test_*.cpp")
TEST_SRCS := $(filter-out $(TEST_MAIN_SRC), $(TEST_SRCS))
TEST_CU_SRCS := $(shell find src/$(PROJECT) -name "test_*.cu")
GTEST_SRC := src/gtest/gtest-all.cpp
# TOOL_SRCS are the source files for the tool binaries
TOOL_SRCS := $(shell find tools -name "*.cpp")
# EXAMPLE_SRCS are the source files for the example binaries
EXAMPLE_SRCS := $(shell find examples -name "*.cpp")
# BUILD_INCLUDE_DIR contains any generated header files we want to include.
BUILD_INCLUDE_DIR := $(BUILD_DIR)/src
# PROTO_SRCS are the protocol buffer definitions
PROTO_SRC_DIR := src/$(PROJECT)/proto
PROTO_SRCS := $(wildcard $(PROTO_SRC_DIR)/*.proto)
# PROTO_BUILD_DIR will contain the .cc and obj files generated from
# PROTO_SRCS; PROTO_BUILD_INCLUDE_DIR will contain the .h header files
PROTO_BUILD_DIR := $(BUILD_DIR)/$(PROTO_SRC_DIR)
PROTO_BUILD_INCLUDE_DIR := $(BUILD_INCLUDE_DIR)/$(PROJECT)/proto
# NONGEN_CXX_SRCS includes all source/header files except those generated
# automatically (e.g., by proto).
NONGEN_CXX_SRCS := $(shell find \src/$(PROJECT) \include/$(PROJECT) \python/$(PROJECT) \matlab/+$(PROJECT)/private \examples \tools \-name "*.cpp" -or -name "*.hpp" -or -name "*.cu" -or -name "*.cuh")
LINT_SCRIPT := scripts/cpp_lint.py
LINT_OUTPUT_DIR := $(BUILD_DIR)/.lint
LINT_EXT := lint.txt
LINT_OUTPUTS := $(addsuffix .$(LINT_EXT), $(addprefix $(LINT_OUTPUT_DIR)/, $(NONGEN_CXX_SRCS)))
EMPTY_LINT_REPORT := $(BUILD_DIR)/.$(LINT_EXT)
NONEMPTY_LINT_REPORT := $(BUILD_DIR)/$(LINT_EXT)
# PY$(PROJECT)_SRC is the python wrapper for $(PROJECT)
PY$(PROJECT)_SRC := python/$(PROJECT)/_$(PROJECT).cpp
PY$(PROJECT)_SO := python/$(PROJECT)/_$(PROJECT).so
PY$(PROJECT)_HXX := include/$(PROJECT)/layers/python_layer.hpp
# MAT$(PROJECT)_SRC is the mex entrance point of matlab package for $(PROJECT)
MAT$(PROJECT)_SRC := matlab/+$(PROJECT)/private/$(PROJECT)_.cpp
ifneq ($(MATLAB_DIR),)MAT_SO_EXT := $(shell $(MATLAB_DIR)/bin/mexext)
endif
MAT$(PROJECT)_SO := matlab/+$(PROJECT)/private/$(PROJECT)_.$(MAT_SO_EXT)##############################
# Derive generated files
##############################
# The generated files for protocol buffers
PROTO_GEN_HEADER_SRCS := $(addprefix $(PROTO_BUILD_DIR)/, \$(notdir ${PROTO_SRCS:.proto=.pb.h}))
PROTO_GEN_HEADER := $(addprefix $(PROTO_BUILD_INCLUDE_DIR)/, \$(notdir ${PROTO_SRCS:.proto=.pb.h}))
PROTO_GEN_CC := $(addprefix $(BUILD_DIR)/, ${PROTO_SRCS:.proto=.pb.cc})
PY_PROTO_BUILD_DIR := python/$(PROJECT)/proto
PY_PROTO_INIT := python/$(PROJECT)/proto/__init__.py
PROTO_GEN_PY := $(foreach file,${PROTO_SRCS:.proto=_pb2.py}, \$(PY_PROTO_BUILD_DIR)/$(notdir $(file)))
# The objects corresponding to the source files
# These objects will be linked into the final shared library, so we
# exclude the tool, example, and test objects.
CXX_OBJS := $(addprefix $(BUILD_DIR)/, ${CXX_SRCS:.cpp=.o})
CU_OBJS := $(addprefix $(BUILD_DIR)/cuda/, ${CU_SRCS:.cu=.o})
PROTO_OBJS := ${PROTO_GEN_CC:.cc=.o}
OBJS := $(PROTO_OBJS) $(CXX_OBJS) $(CU_OBJS)
# tool, example, and test objects
TOOL_OBJS := $(addprefix $(BUILD_DIR)/, ${TOOL_SRCS:.cpp=.o})
TOOL_BUILD_DIR := $(BUILD_DIR)/tools
TEST_CXX_BUILD_DIR := $(BUILD_DIR)/src/$(PROJECT)/test
TEST_CU_BUILD_DIR := $(BUILD_DIR)/cuda/src/$(PROJECT)/test
TEST_CXX_OBJS := $(addprefix $(BUILD_DIR)/, ${TEST_SRCS:.cpp=.o})
TEST_CU_OBJS := $(addprefix $(BUILD_DIR)/cuda/, ${TEST_CU_SRCS:.cu=.o})
TEST_OBJS := $(TEST_CXX_OBJS) $(TEST_CU_OBJS)
GTEST_OBJ := $(addprefix $(BUILD_DIR)/, ${GTEST_SRC:.cpp=.o})
EXAMPLE_OBJS := $(addprefix $(BUILD_DIR)/, ${EXAMPLE_SRCS:.cpp=.o})
# Output files for automatic dependency generation
DEPS := ${CXX_OBJS:.o=.d} ${CU_OBJS:.o=.d} ${TEST_CXX_OBJS:.o=.d} \${TEST_CU_OBJS:.o=.d} $(BUILD_DIR)/${MAT$(PROJECT)_SO:.$(MAT_SO_EXT)=.d}
# tool, example, and test bins
TOOL_BINS := ${TOOL_OBJS:.o=.bin}
EXAMPLE_BINS := ${EXAMPLE_OBJS:.o=.bin}
# symlinks to tool bins without the ".bin" extension
TOOL_BIN_LINKS := ${TOOL_BINS:.bin=}
# Put the test binaries in build/test for convenience.
TEST_BIN_DIR := $(BUILD_DIR)/test
TEST_CU_BINS := $(addsuffix .testbin,$(addprefix $(TEST_BIN_DIR)/, \$(foreach obj,$(TEST_CU_OBJS),$(basename $(notdir $(obj))))))
TEST_CXX_BINS := $(addsuffix .testbin,$(addprefix $(TEST_BIN_DIR)/, \$(foreach obj,$(TEST_CXX_OBJS),$(basename $(notdir $(obj))))))
TEST_BINS := $(TEST_CXX_BINS) $(TEST_CU_BINS)
# TEST_ALL_BIN is the test binary that links caffe dynamically.
TEST_ALL_BIN := $(TEST_BIN_DIR)/test_all.testbin##############################
# Derive compiler warning dump locations
##############################
WARNS_EXT := warnings.txt
CXX_WARNS := $(addprefix $(BUILD_DIR)/, ${CXX_SRCS:.cpp=.o.$(WARNS_EXT)})
CU_WARNS := $(addprefix $(BUILD_DIR)/cuda/, ${CU_SRCS:.cu=.o.$(WARNS_EXT)})
TOOL_WARNS := $(addprefix $(BUILD_DIR)/, ${TOOL_SRCS:.cpp=.o.$(WARNS_EXT)})
EXAMPLE_WARNS := $(addprefix $(BUILD_DIR)/, ${EXAMPLE_SRCS:.cpp=.o.$(WARNS_EXT)})
TEST_WARNS := $(addprefix $(BUILD_DIR)/, ${TEST_SRCS:.cpp=.o.$(WARNS_EXT)})
TEST_CU_WARNS := $(addprefix $(BUILD_DIR)/cuda/, ${TEST_CU_SRCS:.cu=.o.$(WARNS_EXT)})
ALL_CXX_WARNS := $(CXX_WARNS) $(TOOL_WARNS) $(EXAMPLE_WARNS) $(TEST_WARNS)
ALL_CU_WARNS := $(CU_WARNS) $(TEST_CU_WARNS)
ALL_WARNS := $(ALL_CXX_WARNS) $(ALL_CU_WARNS)EMPTY_WARN_REPORT := $(BUILD_DIR)/.$(WARNS_EXT)
NONEMPTY_WARN_REPORT := $(BUILD_DIR)/$(WARNS_EXT)##############################
# Derive include and lib directories
##############################
CUDA_INCLUDE_DIR := $(CUDA_DIR)/includeCUDA_LIB_DIR :=
# add <cuda>/lib64 only if it exists
ifneq ("$(wildcard $(CUDA_DIR)/lib64)","")CUDA_LIB_DIR += $(CUDA_DIR)/lib64
endif
CUDA_LIB_DIR += $(CUDA_DIR)/libINCLUDE_DIRS += $(BUILD_INCLUDE_DIR) ./src ./include
ifneq ($(CPU_ONLY), 1)INCLUDE_DIRS += $(CUDA_INCLUDE_DIR)LIBRARY_DIRS += $(CUDA_LIB_DIR)LIBRARIES := cudart cublas curand
endifLIBRARIES += glog gflags protobuf boost_system boost_filesystem boost_regex m hdf5_serial_hl hdf5_serial# handle IO dependencies
USE_LEVELDB ?= 1
USE_LMDB ?= 1
USE_OPENCV ?= 1ifeq ($(USE_LEVELDB), 1)LIBRARIES += leveldb snappy
endif
ifeq ($(USE_LMDB), 1)LIBRARIES += lmdb
endif
ifeq ($(USE_OPENCV), 1)LIBRARIES += opencv_core opencv_highgui opencv_imgprocifeq ($(OPENCV_VERSION), 3)LIBRARIES += opencv_imgcodecs opencv_videoioendifendif
PYTHON_LIBRARIES ?= boost_python python2.7
WARNINGS := -Wall -Wno-sign-compare##############################
# Set build directories
##############################DISTRIBUTE_DIR ?= distribute
DISTRIBUTE_SUBDIRS := $(DISTRIBUTE_DIR)/bin $(DISTRIBUTE_DIR)/lib
DIST_ALIASES := dist
ifneq ($(strip $(DISTRIBUTE_DIR)),distribute)DIST_ALIASES += distribute
endifALL_BUILD_DIRS := $(sort $(BUILD_DIR) $(addprefix $(BUILD_DIR)/, $(SRC_DIRS)) \$(addprefix $(BUILD_DIR)/cuda/, $(SRC_DIRS)) \$(LIB_BUILD_DIR) $(TEST_BIN_DIR) $(PY_PROTO_BUILD_DIR) $(LINT_OUTPUT_DIR) \$(DISTRIBUTE_SUBDIRS) $(PROTO_BUILD_INCLUDE_DIR))##############################
# Set directory for Doxygen-generated documentation
##############################
DOXYGEN_CONFIG_FILE ?= ./.Doxyfile
# should be the same as OUTPUT_DIRECTORY in the .Doxyfile
DOXYGEN_OUTPUT_DIR ?= ./doxygen
DOXYGEN_COMMAND ?= doxygen
# All the files that might have Doxygen documentation.
DOXYGEN_SOURCES := $(shell find \src/$(PROJECT) \include/$(PROJECT) \python/ \matlab/ \examples \tools \-name "*.cpp" -or -name "*.hpp" -or -name "*.cu" -or -name "*.cuh" -or \-name "*.py" -or -name "*.m")
DOXYGEN_SOURCES += $(DOXYGEN_CONFIG_FILE)##############################
# Configure build
############################### Determine platform
UNAME := $(shell uname -s)
ifeq ($(UNAME), Linux)LINUX := 1
else ifeq ($(UNAME), Darwin)OSX := 1OSX_MAJOR_VERSION := $(shell sw_vers -productVersion | cut -f 1 -d .)OSX_MINOR_VERSION := $(shell sw_vers -productVersion | cut -f 2 -d .)
endif# Linux
ifeq ($(LINUX), 1)CXX ?= /usr/bin/g++GCCVERSION := $(shell $(CXX) -dumpversion | cut -f1,2 -d.)# older versions of gcc are too dumb to build boost with -Wuninitalizedifeq ($(shell echo | awk '{exit $(GCCVERSION) < 4.6;}'), 1)WARNINGS += -Wno-uninitializedendif# boost::thread is reasonably called boost_thread (compare OS X)# We will also explicitly add stdc++ to the link target.LIBRARIES += boost_thread stdc++ boost_regexVERSIONFLAGS += -Wl,-soname,$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../lib
endif# OS X:
# clang++ instead of g++
# libstdc++ for NVCC compatibility on OS X >= 10.9 with CUDA < 7.0
ifeq ($(OSX), 1)CXX := /usr/bin/clang++ifneq ($(CPU_ONLY), 1)CUDA_VERSION := $(shell $(CUDA_DIR)/bin/nvcc -V | grep -o 'release [0-9.]*' | tr -d '[a-z ]')ifeq ($(shell echo | awk '{exit $(CUDA_VERSION) < 7.0;}'), 1)CXXFLAGS += -stdlib=libstdc++LINKFLAGS += -stdlib=libstdc++endif# clang throws this warning for cuda headersWARNINGS += -Wno-unneeded-internal-declaration# 10.11 strips DYLD_* env vars so link CUDA (rpath is available on 10.5+)OSX_10_OR_LATER   := $(shell [ $(OSX_MAJOR_VERSION) -ge 10 ] && echo true)OSX_10_5_OR_LATER := $(shell [ $(OSX_MINOR_VERSION) -ge 5 ] && echo true)ifeq ($(OSX_10_OR_LATER),true)ifeq ($(OSX_10_5_OR_LATER),true)LDFLAGS += -Wl,-rpath,$(CUDA_LIB_DIR)endifendifendif# gtest needs to use its own tuple to not conflict with clangCOMMON_FLAGS += -DGTEST_USE_OWN_TR1_TUPLE=1# boost::thread is called boost_thread-mt to mark multithreading on OS XLIBRARIES += boost_thread-mt# we need to explicitly ask for the rpath to be obeyedORIGIN := @loader_pathVERSIONFLAGS += -Wl,-install_name,@rpath/$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../../build/lib
elseORIGIN := \$$ORIGIN
endif# Custom compiler
ifdef CUSTOM_CXXCXX := $(CUSTOM_CXX)
endif# Static linking
ifneq (,$(findstring clang++,$(CXX)))STATIC_LINK_COMMAND := -Wl,-force_load $(STATIC_NAME)
else ifneq (,$(findstring g++,$(CXX)))STATIC_LINK_COMMAND := -Wl,--whole-archive $(STATIC_NAME) -Wl,--no-whole-archive
else# The following line must not be indented with a tab, since we are not inside a target$(error Cannot static link with the $(CXX) compiler)
endif# Debugging
ifeq ($(DEBUG), 1)COMMON_FLAGS += -DDEBUG -g -O0NVCCFLAGS += -G
elseCOMMON_FLAGS += -DNDEBUG -O2
endif# cuDNN acceleration configuration.
ifeq ($(USE_CUDNN), 1)LIBRARIES += cudnnCOMMON_FLAGS += -DUSE_CUDNN
endif# configure IO libraries
ifeq ($(USE_OPENCV), 1)COMMON_FLAGS += -DUSE_OPENCV
endif
ifeq ($(USE_LEVELDB), 1)COMMON_FLAGS += -DUSE_LEVELDB
endif
ifeq ($(USE_LMDB), 1)COMMON_FLAGS += -DUSE_LMDB
ifeq ($(ALLOW_LMDB_NOLOCK), 1)COMMON_FLAGS += -DALLOW_LMDB_NOLOCK
endif
endif# CPU-only configuration
ifeq ($(CPU_ONLY), 1)OBJS := $(PROTO_OBJS) $(CXX_OBJS)TEST_OBJS := $(TEST_CXX_OBJS)TEST_BINS := $(TEST_CXX_BINS)ALL_WARNS := $(ALL_CXX_WARNS)TEST_FILTER := --gtest_filter="-*GPU*"COMMON_FLAGS += -DCPU_ONLY
endif# Python layer support
ifeq ($(WITH_PYTHON_LAYER), 1)COMMON_FLAGS += -DWITH_PYTHON_LAYERLIBRARIES += $(PYTHON_LIBRARIES)
endif# BLAS configuration (default = ATLAS)
BLAS ?= atlas
ifeq ($(BLAS), mkl)# MKLLIBRARIES += mkl_rtCOMMON_FLAGS += -DUSE_MKLMKLROOT ?= /opt/intel/mklBLAS_INCLUDE ?= $(MKLROOT)/includeBLAS_LIB ?= $(MKLROOT)/lib $(MKLROOT)/lib/intel64
else ifeq ($(BLAS), open)# OpenBLASLIBRARIES += openblas
else# ATLASifeq ($(LINUX), 1)ifeq ($(BLAS), atlas)# Linux simply has cblas and atlasLIBRARIES += cblas atlasendifelse ifeq ($(OSX), 1)# OS X packages atlas as the vecLib frameworkLIBRARIES += cblas# 10.10 has accelerate while 10.9 has veclibXCODE_CLT_VER := $(shell pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep 'version' | sed 's/[^0-9]*\([0-9]\).*/\1/')XCODE_CLT_GEQ_7 := $(shell [ $(XCODE_CLT_VER) -gt 6 ] && echo 1)XCODE_CLT_GEQ_6 := $(shell [ $(XCODE_CLT_VER) -gt 5 ] && echo 1)ifeq ($(XCODE_CLT_GEQ_7), 1)BLAS_INCLUDE ?= /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/$(shell ls /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ | sort | tail -1)/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/Headerselse ifeq ($(XCODE_CLT_GEQ_6), 1)BLAS_INCLUDE ?= /System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/LDFLAGS += -framework AccelerateelseBLAS_INCLUDE ?= /System/Library/Frameworks/vecLib.framework/Versions/Current/Headers/LDFLAGS += -framework vecLibendifendif
endif
INCLUDE_DIRS += $(BLAS_INCLUDE)
LIBRARY_DIRS += $(BLAS_LIB)LIBRARY_DIRS += $(LIB_BUILD_DIR)# Automatic dependency generation (nvcc is handled separately)
CXXFLAGS += -MMD -MP# Complete build flags.
COMMON_FLAGS += $(foreach includedir,$(INCLUDE_DIRS),-isystem $(includedir))
CXXFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS)
# NVCCFLAGS += -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
# mex may invoke an older gcc that is too liberal with -Wuninitalized
MATLAB_CXXFLAGS := $(CXXFLAGS) -Wno-uninitialized
LINKFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS)USE_PKG_CONFIG ?= 0
ifeq ($(USE_PKG_CONFIG), 1)PKG_CONFIG := $(shell pkg-config opencv --libs)
elsePKG_CONFIG :=
endif
LDFLAGS += $(foreach librarydir,$(LIBRARY_DIRS),-L$(librarydir)) $(PKG_CONFIG) \$(foreach library,$(LIBRARIES),-l$(library))
PYTHON_LDFLAGS := $(LDFLAGS) $(foreach library,$(PYTHON_LIBRARIES),-l$(library))# 'superclean' target recursively* deletes all files ending with an extension
# in $(SUPERCLEAN_EXTS) below.  This may be useful if you've built older
# versions of Caffe that do not place all generated files in a location known
# to the 'clean' target.
#
# 'supercleanlist' will list the files to be deleted by make superclean.
#
# * Recursive with the exception that symbolic links are never followed, per the
# default behavior of 'find'.
SUPERCLEAN_EXTS := .so .a .o .bin .testbin .pb.cc .pb.h _pb2.py .cuo# Set the sub-targets of the 'everything' target.
EVERYTHING_TARGETS := all py$(PROJECT) test warn lint
# Only build matcaffe as part of "everything" if MATLAB_DIR is specified.
ifneq ($(MATLAB_DIR),)EVERYTHING_TARGETS += mat$(PROJECT)
endif##############################
# Define build targets
##############################
.PHONY: all lib test clean docs linecount lint lintclean tools examples $(DIST_ALIASES) \py mat py$(PROJECT) mat$(PROJECT) proto runtest \superclean supercleanlist supercleanfiles warn everythingall: lib tools exampleslib: $(STATIC_NAME) $(DYNAMIC_NAME)everything: $(EVERYTHING_TARGETS)linecount:cloc --read-lang-def=$(PROJECT).cloc \src/$(PROJECT) include/$(PROJECT) tools examples \python matlablint: $(EMPTY_LINT_REPORT)lintclean:@ $(RM) -r $(LINT_OUTPUT_DIR) $(EMPTY_LINT_REPORT) $(NONEMPTY_LINT_REPORT)docs: $(DOXYGEN_OUTPUT_DIR)@ cd ./docs ; ln -sfn ../$(DOXYGEN_OUTPUT_DIR)/html doxygen$(DOXYGEN_OUTPUT_DIR): $(DOXYGEN_CONFIG_FILE) $(DOXYGEN_SOURCES)$(DOXYGEN_COMMAND) $(DOXYGEN_CONFIG_FILE)$(EMPTY_LINT_REPORT): $(LINT_OUTPUTS) | $(BUILD_DIR)@ cat $(LINT_OUTPUTS) > $@@ if [ -s "$@" ]; then \cat $@; \mv $@ $(NONEMPTY_LINT_REPORT); \echo "Found one or more lint errors."; \exit 1; \fi; \$(RM) $(NONEMPTY_LINT_REPORT); \echo "No lint errors!";$(LINT_OUTPUTS): $(LINT_OUTPUT_DIR)/%.lint.txt : % $(LINT_SCRIPT) | $(LINT_OUTPUT_DIR)@ mkdir -p $(dir $@)@ python $(LINT_SCRIPT) $< 2>&1 \| grep -v "^Done processing " \| grep -v "^Total errors found: 0" \> $@ \|| truetest: $(TEST_ALL_BIN) $(TEST_ALL_DYNLINK_BIN) $(TEST_BINS)tools: $(TOOL_BINS) $(TOOL_BIN_LINKS)examples: $(EXAMPLE_BINS)py$(PROJECT): pypy: $(PY$(PROJECT)_SO) $(PROTO_GEN_PY)$(PY$(PROJECT)_SO): $(PY$(PROJECT)_SRC) $(PY$(PROJECT)_HXX) | $(DYNAMIC_NAME)@ echo CXX/LD -o $@ $<$(Q)$(CXX) -shared -o $@ $(PY$(PROJECT)_SRC) \-o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(PYTHON_LDFLAGS) \-Wl,-rpath,$(ORIGIN)/../../build/libmat$(PROJECT): matmat: $(MAT$(PROJECT)_SO)$(MAT$(PROJECT)_SO): $(MAT$(PROJECT)_SRC) $(STATIC_NAME)@ if [ -z "$(MATLAB_DIR)" ]; then \echo "MATLAB_DIR must be specified in $(CONFIG_FILE)" \"to build mat$(PROJECT)."; \exit 1; \fi@ echo MEX $<$(Q)$(MATLAB_DIR)/bin/mex $(MAT$(PROJECT)_SRC) \CXX="$(CXX)" \CXXFLAGS="\$$CXXFLAGS $(MATLAB_CXXFLAGS)" \CXXLIBS="\$$CXXLIBS $(STATIC_LINK_COMMAND) $(LDFLAGS)" -output $@@ if [ -f "$(PROJECT)_.d" ]; then \mv -f $(PROJECT)_.d $(BUILD_DIR)/${MAT$(PROJECT)_SO:.$(MAT_SO_EXT)=.d}; \firuntest: $(TEST_ALL_BIN)$(TOOL_BUILD_DIR)/caffe$(TEST_ALL_BIN) $(TEST_GPUID) --gtest_shuffle $(TEST_FILTER)pytest: pycd python; python -m unittest discover -s caffe/testmattest: matcd matlab; $(MATLAB_DIR)/bin/matlab -nodisplay -r 'caffe.run_tests(), exit()'warn: $(EMPTY_WARN_REPORT)$(EMPTY_WARN_REPORT): $(ALL_WARNS) | $(BUILD_DIR)@ cat $(ALL_WARNS) > $@@ if [ -s "$@" ]; then \cat $@; \mv $@ $(NONEMPTY_WARN_REPORT); \echo "Compiler produced one or more warnings."; \exit 1; \fi; \$(RM) $(NONEMPTY_WARN_REPORT); \echo "No compiler warnings!";$(ALL_WARNS): %.o.$(WARNS_EXT) : %.o$(BUILD_DIR_LINK): $(BUILD_DIR)/.linked# Create a target ".linked" in this BUILD_DIR to tell Make that the "build" link
# is currently correct, then delete the one in the OTHER_BUILD_DIR in case it
# exists and $(DEBUG) is toggled later.
$(BUILD_DIR)/.linked:@ mkdir -p $(BUILD_DIR)@ $(RM) $(OTHER_BUILD_DIR)/.linked@ $(RM) -r $(BUILD_DIR_LINK)@ ln -s $(BUILD_DIR) $(BUILD_DIR_LINK)@ touch $@$(ALL_BUILD_DIRS): | $(BUILD_DIR_LINK)@ mkdir -p $@$(DYNAMIC_NAME): $(OBJS) | $(LIB_BUILD_DIR)@ echo LD -o $@$(Q)$(CXX) -shared -o $@ $(OBJS) $(VERSIONFLAGS) $(LINKFLAGS) $(LDFLAGS)@ cd $(BUILD_DIR)/lib; rm -f $(DYNAMIC_NAME_SHORT);   ln -s $(DYNAMIC_VERSIONED_NAME_SHORT) $(DYNAMIC_NAME_SHORT)$(STATIC_NAME): $(OBJS) | $(LIB_BUILD_DIR)@ echo AR -o $@$(Q)ar rcs $@ $(OBJS)$(BUILD_DIR)/%.o: %.cpp | $(ALL_BUILD_DIRS)@ echo CXX $<$(Q)$(CXX) $< $(CXXFLAGS) -c -o $@ 2> $@.$(WARNS_EXT) \|| (cat $@.$(WARNS_EXT); exit 1)@ cat $@.$(WARNS_EXT)$(PROTO_BUILD_DIR)/%.pb.o: $(PROTO_BUILD_DIR)/%.pb.cc $(PROTO_GEN_HEADER) \| $(PROTO_BUILD_DIR)@ echo CXX $<$(Q)$(CXX) $< $(CXXFLAGS) -c -o $@ 2> $@.$(WARNS_EXT) \|| (cat $@.$(WARNS_EXT); exit 1)@ cat $@.$(WARNS_EXT)$(BUILD_DIR)/cuda/%.o: %.cu | $(ALL_BUILD_DIRS)@ echo NVCC $<$(Q)$(CUDA_DIR)/bin/nvcc $(NVCCFLAGS) $(CUDA_ARCH) -M $< -o ${@:.o=.d} \-odir $(@D)$(Q)$(CUDA_DIR)/bin/nvcc $(NVCCFLAGS) $(CUDA_ARCH) -c $< -o $@ 2> $@.$(WARNS_EXT) \|| (cat $@.$(WARNS_EXT); exit 1)@ cat $@.$(WARNS_EXT)$(TEST_ALL_BIN): $(TEST_MAIN_SRC) $(TEST_OBJS) $(GTEST_OBJ) \| $(DYNAMIC_NAME) $(TEST_BIN_DIR)@ echo CXX/LD -o $@ $<$(Q)$(CXX) $(TEST_MAIN_SRC) $(TEST_OBJS) $(GTEST_OBJ) \-o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib$(TEST_CU_BINS): $(TEST_BIN_DIR)/%.testbin: $(TEST_CU_BUILD_DIR)/%.o \$(GTEST_OBJ) | $(DYNAMIC_NAME) $(TEST_BIN_DIR)@ echo LD $<$(Q)$(CXX) $(TEST_MAIN_SRC) $< $(GTEST_OBJ) \-o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib$(TEST_CXX_BINS): $(TEST_BIN_DIR)/%.testbin: $(TEST_CXX_BUILD_DIR)/%.o \$(GTEST_OBJ) | $(DYNAMIC_NAME) $(TEST_BIN_DIR)@ echo LD $<$(Q)$(CXX) $(TEST_MAIN_SRC) $< $(GTEST_OBJ) \-o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib# Target for extension-less symlinks to tool binaries with extension '*.bin'.
$(TOOL_BUILD_DIR)/%: $(TOOL_BUILD_DIR)/%.bin | $(TOOL_BUILD_DIR)@ $(RM) $@@ ln -s $(notdir $<) $@$(TOOL_BINS): %.bin : %.o | $(DYNAMIC_NAME)@ echo CXX/LD -o $@$(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(LDFLAGS) \-Wl,-rpath,$(ORIGIN)/../lib$(EXAMPLE_BINS): %.bin : %.o | $(DYNAMIC_NAME)@ echo CXX/LD -o $@$(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(LDFLAGS) \-Wl,-rpath,$(ORIGIN)/../../libproto: $(PROTO_GEN_CC) $(PROTO_GEN_HEADER)$(PROTO_BUILD_DIR)/%.pb.cc $(PROTO_BUILD_DIR)/%.pb.h : \$(PROTO_SRC_DIR)/%.proto | $(PROTO_BUILD_DIR)@ echo PROTOC $<$(Q)protoc --proto_path=$(PROTO_SRC_DIR) --cpp_out=$(PROTO_BUILD_DIR) $<$(PY_PROTO_BUILD_DIR)/%_pb2.py : $(PROTO_SRC_DIR)/%.proto \$(PY_PROTO_INIT) | $(PY_PROTO_BUILD_DIR)@ echo PROTOC \(python\) $<$(Q)protoc --proto_path=$(PROTO_SRC_DIR) --python_out=$(PY_PROTO_BUILD_DIR) $<$(PY_PROTO_INIT): | $(PY_PROTO_BUILD_DIR)touch $(PY_PROTO_INIT)clean:@- $(RM) -rf $(ALL_BUILD_DIRS)@- $(RM) -rf $(OTHER_BUILD_DIR)@- $(RM) -rf $(BUILD_DIR_LINK)@- $(RM) -rf $(DISTRIBUTE_DIR)@- $(RM) $(PY$(PROJECT)_SO)@- $(RM) $(MAT$(PROJECT)_SO)supercleanfiles:$(eval SUPERCLEAN_FILES := $(strip \$(foreach ext,$(SUPERCLEAN_EXTS), $(shell find . -name '*$(ext)' \-not -path './data/*'))))supercleanlist: supercleanfiles@ \if [ -z "$(SUPERCLEAN_FILES)" ]; then \echo "No generated files found."; \else \echo $(SUPERCLEAN_FILES) | tr ' ' '\n'; \fisuperclean: clean supercleanfiles@ \if [ -z "$(SUPERCLEAN_FILES)" ]; then \echo "No generated files found."; \else \echo "Deleting the following generated files:"; \echo $(SUPERCLEAN_FILES) | tr ' ' '\n'; \$(RM) $(SUPERCLEAN_FILES); \fi$(DIST_ALIASES): $(DISTRIBUTE_DIR)$(DISTRIBUTE_DIR): all py | $(DISTRIBUTE_SUBDIRS)# add protocp -r src/caffe/proto $(DISTRIBUTE_DIR)/# add includecp -r include $(DISTRIBUTE_DIR)/mkdir -p $(DISTRIBUTE_DIR)/include/caffe/protocp $(PROTO_GEN_HEADER_SRCS) $(DISTRIBUTE_DIR)/include/caffe/proto# add tool and example binariescp $(TOOL_BINS) $(DISTRIBUTE_DIR)/bincp $(EXAMPLE_BINS) $(DISTRIBUTE_DIR)/bin# add librariescp $(STATIC_NAME) $(DISTRIBUTE_DIR)/libinstall -m 644 $(DYNAMIC_NAME) $(DISTRIBUTE_DIR)/libcd $(DISTRIBUTE_DIR)/lib; rm -f $(DYNAMIC_NAME_SHORT);   ln -s $(DYNAMIC_VERSIONED_NAME_SHORT) $(DYNAMIC_NAME_SHORT)# add python - it's not the standard way, indeed...cp -r python $(DISTRIBUTE_DIR)/python-include $(DEPS)

具体的修改为

  1. 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
  2. NVCCFLAGS +=-ccbin=$(CXX) -Xcompiler-fPIC $(COMMON_FLAGS) 改成了
    NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
  3. LIBRARIES += boost_thread stdc++后加boost_regex 改成了
    LIBRARIES += boost_thread stdc++ boost_regex

编译

请确认好在caffe文件夹分支ssd下哦!

make -j8make pymake test -j8# 这个运不运行无所谓 测试一下是否OK
# make runtest -j8# 用来给autoware的那个搜索到的
make distribute

进入文件 DEFINE CPU_ONLY

gedit ~/caffe/distribute/include/caffe/util/device_alternate.hpp

然后在#ifdef CPU_ONLY前面空行处,加一句:

#define CPU_ONLY

可能会遇到的问题

/usr/bin/ld: cannot find -lopenblas

sudo apt install liblapack-dev liblapack3 libopenblas-base libopenblas-dev

更多问题见引用参考

GPU版本编译错误见引用参考:Ubuntu 16.04配置caffe-ssd

导入模型文件

这个模型 models_VGGNet_VOC0712_SSD_512x512_ft.tar:百度YP链接
然后解压把VGGNet文件夹整个拷贝到caffe的models文件夹内

接着我们,然后拖到最后

gedit ~/caffe/models/VGGNet/VOC0712/SSD_512x512_ft/deploy.prototxt

这里的

save_output_param {label_map_file: "/home/udi/caffe/data/VOC0712/labelmap_voc.prototxt"}

是需要改成绝对路径的

Autoware 适配

修改CMakeLists.txt

不想看具体的直接复制全选粘贴:【注意版本V1.14可以这么干】

cmake_minimum_required(VERSION 2.8.12)
project(vision_ssd_detect)include(FindPkgConfig)find_package(autoware_build_flags REQUIRED)
find_package(catkin REQUIRED COMPONENTSautoware_config_msgsautoware_msgscv_bridgeimage_transportroscppsensor_msgsstd_msgstf
)# find_package(CUDA)
find_package(OpenCV REQUIRED)catkin_package()set(CMAKE_CXX_FLAGS "-O2 -g -Wall ${CMAKE_CXX_FLAGS}")include_directories(${catkin_INCLUDE_DIRS}
)#####SSD########
##############################SSD'sFORK of CAFFE NEEDS TO BE PREVIOUSLY COMPILED####################
# set(SSD_CAFFE_PATH "$ENV{HOME}/ssdcaffe/distribute")
set(SSD_CAFFE_PATH "$ENV{HOME}/caffe/distribute")
##################################################################################################### AW_CHECK_CUDA()# if(USE_CUDA AND EXISTS "${SSD_CAFFE_PATH}")
if(EXISTS "${SSD_CAFFE_PATH}")include_directories(${CUDA_INCLUDE_DIRS})if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "^arm")link_directories(/usr/lib/arm-linux-gnueabihf/tegra)endif()add_executable(vision_ssd_detectsrc/vision_ssd_detect.cppsrc/vision_ssd_detect_node.cpp)target_link_libraries(vision_ssd_detect${catkin_LIBRARIES}${OpenCV_LIBRARIES}# ${CUDA_LIBRARIES}# ${CUDA_CUBLAS_LIBRARIES}# ${CUDA_curand_LIBRARY}${SSD_CAFFE_PATH}/lib/libcaffe.so${SSD_CAFFE_PATH}/lib/libcaffe.so.1.0.0-rc3# need to link{1} /home/${USER_NAME}/ssdcaffe/distribute/lib/libcaffe.so.1.0.0-rc3 to shared lib path{2}# 1-1: sudo cp # 1-2: ln -s # 2-1: /usr/lib/x86_64-linux-gnu/# 2-2: /usr/libglog)target_include_directories(vision_ssd_detect PRIVATEinclude${SSD_CAFFE_PATH}/include)add_dependencies(vision_ssd_detect${catkin_EXPORTED_TARGETS})install(DIRECTORY include/DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})install(TARGETS vision_ssd_detectARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})install(DIRECTORY launch/DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch# PATTERN ".svn" EXCLUDE)
else()message("'SSD/Caffe' is not installed. 'ssd_unc' will not be built.")
endif()

具体的修改为

  1. 注释# find_package(CUDA)
  2. caffe的文件夹名修改了【因为有些gitee上是ssdcaffe的文件名的话就不需要改这条,如果是按照上面步骤来的 改就行】
    # set(SSD_CAFFE_PATH "$ENV{HOME}/ssdcaffe/distribute")
    set(SSD_CAFFE_PATH "$ENV{HOME}/caffe/distribute")
    
  3. 注释# AW_CHECK_CUDA()
  4. if(USE_CUDA AND EXISTS "${SSD_CAFFE_PATH}")改为了:if(EXISTS "${SSD_CAFFE_PATH}"),即删除了CUDA
  5. 链接库进行了修改:注释掉了CUDA相关,增加了libcaffe.so.1.0.0-rcc3
      target_link_libraries(vision_ssd_detect${catkin_LIBRARIES}${OpenCV_LIBRARIES}# ${CUDA_LIBRARIES}# ${CUDA_CUBLAS_LIBRARIES}# ${CUDA_curand_LIBRARY}${SSD_CAFFE_PATH}/lib/libcaffe.so${SSD_CAFFE_PATH}/lib/libcaffe.so.1.0.0-rc3# need to link{1} /home/${USER_NAME}/ssdcaffe/distribute/lib/libcaffe.so.1.0.0-rc3 to shared lib path{2}glog)
    
  6. 注释# PATTERN ".svn" EXCLUDE,如不删除此句 则不会进行编译

链接库

其实这个点在CMakeList里写了

# need to link{1} /home/${USER_NAME}/ssdcaffe/distribute/lib/libcaffe.so.1.0.0-rc3 to shared lib path{2}
# 1-1: sudo cp
# 1-2: ln -s
# 2-1: /usr/lib/x86_64-linux-gnu/
# 2-2: /usr/lib

自己替换USER_NAME

sudo ln -s /home/${USER_NAME}/caffe/distribute/lib/libcaffe.so.1.0.0-rc3 /usr/lib

修改launch 虽然界面也能勾选

gedit ~/autoware.ai/src/autoware/core_perception/vision_ssd_detect/launch/vision_ssd_detect.launch #第二行的true改成false
<arg name="use_gpu" default="false"/>

编译Autoware

cd ~/autoware.ai
colcon build

如果是按照上面的流程做的 应该不会有报错了

运行

运行runtime_manager

roslaunch runtime_manager runtime_manager.launch

播放BAG

播放一个带image_raw 或者带图片的输出[订阅节点名字可以被修改]输出的bag包

运行vision_ssd_detect节点


其中第二步的选择文件更改到上面说到的模型文件中去,两个都要改,注意看默认的后缀别放错了

然后打开RVIZ添加Panels - ImageViewerPlugin

效果示意


GPU

GPU版本的修改为:

CUDA安装

深度学习 最快方式安装CUDA和 Nvidia Driver 按照这篇文章的就OK
自己又按照10.0的写了一遍在CSDN上,直接跳转第一部分即可

caffe里的Makefile.config

等有空再详细讲,直接复制粘贴【CUDA用的10.0】

## 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 layers
# USE_OPENCV := 0
# 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 := 3# 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-10.0
# 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 lines after *_35 for compatibility.
CUDA_ARCH := -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_61,code=sm_61# BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
# BLAS := atlas
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 := /path/to/your/blas
# BLAS_LIB := /path/to/your/blas# 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_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)/anaconda2
# PYTHON_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/lib
# PYTHON_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 := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial# 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# 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 ?= @

关于Eigen的版本

  1. 这里有点棘手的就是 libeigen3-dev这个吧… 系统的包版本是3.3.4 而且还没能升级【ubuntu 18.04】也不知道啥时候安好的,然后呢 Autoware这边detect节点编译的时候就会说:
    GPU require Eigen vesion >=3.3.7
  2. 然后呢这就得卸载吧
  3. 然后呢这个一卸载就发现:接连着要给我把整个ROS都卸了
  4. 然后呢我就… 用了大家很反感的
    sudo rm -rf /usr/include/eigen3*
    sudo rm -rf /usr/lib/cmake/eigen3*
    

    我感觉是有风险的 只是我现在… 还没感觉到这个BUG在哪里

  5. 然后呢再把源码编译的usr/local/include/eigen3给链接到这个/usr/include上
  6. 然后呢我就发现 咦是不是不用删sudo rm -rf直接链接也可以…【事实证明:不可以】

源码安装法

cd && wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz
mkdir eigen && tar --strip-components=1 -xzvf eigen-3.3.7.tar.gz -C eigen
cd eigen && mkdir build && cd build && cmake .. && make# install need administrative privileges
sudo make install#Remove downloaded and temporary files
cd && rm -rf eigen-3.3.7.tar.gz

接着就是软链接【放心可以撤回的】此条命令详情见:ubuntu文件夹建立软链接方法
2:文件夹建立软链接(用绝对地址)
ln -s 源地址 目的地址
比如我把linux文件系统rootfs_dir软链接到/home/jyg/目录下
ln -s /opt/linux/rootfs_dir /home/jyg/rootfs_dir就可以了

sudo ln -s /usr/local/include/eigen3 /usr/include/eigen3

接着编译:

AUTOWARE_COMPILE_WITH_CUDA=1 colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release

编译cafffe

make -j8make pymake test -j8# 这个运不运行无所谓 测试一下是否OK
# make runtest -j8# 用来给autoware的那个搜索到的
make distribute

报错类型

atal error: caffe/caffe.hpp: No such file or directory #include “caffe/caffe.hpp”

没有进行make distribute的操作

make test -j8的时候报错

错误如下:

Makefile:604: recipe for target '.build_release/test/test_im2col_kernel.testbin' failed
make: *** [.build_release/test/test_im2col_kernel.testbin] Error 1
make: *** Waiting for unfinished jobs....
.build_release/lib/libcaffe.so: undefined reference to `caffe::BaseConvolutionLayer<double>::backward_gpu_bias(double*, double const*)'
.build_release/lib/libcaffe.so: undefined reference to `caffe::BaseConvolutionLayer<float>::backward_gpu_bias(float*, float const*)'
.build_release/lib/libcaffe.so: undefined reference to `caffe::BaseConvolutionLayer<double>::forward_gpu_gemm(double const*, double const*, double*, bool)'

这个错误似乎是 没有删除之前的build
重新来一遍就好了…【从git clone caffe分支开始】(以前我记得直接rm -rf build*这个文件夹就OK的…)-> 还是make clean把

cd caffe
make clean

编译Autoware with CUDA

AUTOWARE_COMPILE_WITH_CUDA=1 colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release

1.14版本会有define报错

【Autoware】Ubuntu 18.04 ssdcaffe安装与Autoware 检测节点运行相关推荐

  1. ubuntu 18.04.4 安装 bazel

    文章目录 ubuntu 18.04.4 安装 bazel 使用二进制安装程序 1: 安装所需的软件包 2: 运行安装程序 3: 设置环境 ubuntu 18.04.4 安装 bazel 使用二进制安装 ...

  2. skype linux 安装,如何在Ubuntu 18.04上安装Skype

    Skype是世界上最流行的通信应用程序之一,它使您可以拨打免费的在线音频和视频电话,以及可负担得起的拨打全球移动电话和固定电话的国际电话. Skype不是开源应用程序,也不包含在Ubuntu存储库中. ...

  3. 在Ubuntu 18.04中安装JDK 8

    在Ubuntu 18.04中安装JDK 8 安装 Oracle JDK Webupd8 Team维护一个PPA存储库,其中包含适用于所有当前Ubuntu版本的Oracle Java 8安装程序脚本. ...

  4. 在Ubuntu 18.04上安装和使用Tesseract 4

    量子指南 (QUANTRIUM GUIDES) Today, the extraction of information from scanned documents such as letters, ...

  5. ubuntu memcached php,如何在 Ubuntu 18.04 上安装 Memcached

    Memcached 是一个免费的开源高性能内存中键值数据存储. 它最常用于通过从数据库调用的结果缓存各种对象来加速应用程序. 在本教程中,我们将介绍在 Ubuntu 18.04 上安装和配置最新版 M ...

  6. ubuntu19 安装git_在Ubuntu 18.04上安装Git

    步骤1.首先,通过运行以下命令确保您的系统和apt包列表完全更新: apt-get update -y apt-get upgrade -y 第2步.在Ubuntu 18.04上安装Git. 现在让我 ...

  7. linux mint 18.3浏览器,在Linux Mint 19/Ubuntu 18.04中安装Tor Browser浏览器的方法

    本文介绍在Linux Mint 19/Ubuntu 18.04系统中安装Tor Browser浏览器的方法,本文不使用Tor的默认Ubuntu存储库,因为它们包含旧版本的Tor. 一.添加Tor存储库 ...

  8. ubuntu18.04安装python3_如何在 Ubuntu 18.04上安装 Python3.7

    Python 是世界上最流行的编程语言之一,凭借其简单易学的语法,Python是初学者和经验丰富的开发人员的绝佳选择.随着近几年人工智能和大数据的火热,Python流行度更是进一步飙升,有冲顶编程语言 ...

  9. 如何在Ubuntu 18.04上安装Django

    Django是一个免费的开源高级Python Web框架,旨在帮助开发人员构建安全,可扩展和可维护的Web应用程序. 根据您的需要,有不同的方法来安装Django.它可以使用pip在系统范围内安装或在 ...

最新文章

  1. python数据库-mysql
  2. OpenDNSSEC 1.3.12 发布
  3. linux 内核编译错误 gcc: error: elf_i386: No such file or directory
  4. 油管螺纹尺寸对照表_数控加工过程中,如何区分新旧螺纹牌号?
  5. Java程序员的春天!java引用数据类型和基本数据类型区别
  6. 〖Android〗代理与正常网络分开同步CyangenMod源码
  7. 产品观,来自微信张小龙的
  8. jquery ui动态切换主题的一种实现方式
  9. JZTK项目 驾照题库项目servlet层得到的json字符串在浏览器中 汉字部分出现问号?无法正常显示的解决方法
  10. java如何确保单线程_java是如何解决单线程之间的通信问题呢?这篇文章给你答案...
  11. 操作数据库出现错误的查找问题方法
  12. linux取反格式,linux基本命令总结(二)
  13. Python 面向对象编程(一)
  14. Dlib Python 检测人脸特征点 Face Landmark Detection
  15. wps中有公式如何调整间距
  16. 测试用例设计方法——等价类划分法、边界值分析法、场景法、判定表、因果图、错误推测法和正交试验法
  17. 捕鱼里金币掉落的效果
  18. 趣味python3编程_Python趣味编程与精彩实例
  19. Win10自带的录屏功能怎么用?
  20. RSA/ECDSA host key has changed 错误

热门文章

  1. 自动驾驶感知——自动驾驶地图
  2. xshell 瓷砖排列 /发送输入键到所有会话
  3. Vue源码中的对象相等比较
  4. JS.Canvas:镂空文字
  5. linux服务器测试软件,linux服务器常用测试工具及命令
  6. 浏览器如何支持java打印_使用JAVA AWT / jnlp从Web浏览器通过指定的打印机进行打印...
  7. SI522如何兼容:RC522 FM17520 CV520 资料
  8. c语言 遍历文件夹中所有文件名,C# 遍历文件夹下所有子文件夹中的文件,得到文件名...
  9. SpringBoot实现多数据源(二)【Mybatis插件】
  10. 墨西哥付款方式有哪些