当前位置:   article > 正文

关于Ubuntu18.04/20.04安装后的一系列环境配置过程的总结_ubuntu18.04安装后

ubuntu18.04安装后

因某些原因,本博客以后将在以下网址更新~

关于Ubuntu18.04/20.04安装后的一系列环境配置过程的总结_安装好ubuntu18-CSDN博客文章浏览阅读854次。Updating本文所有用到的文件打包供大家下载(不含代码){}:提取码:zwz4--来自百度网盘超级会员v4的分享。_安装好ubuntu18https://blog.csdn.net/M0rtzz/article/details/134085988Updating...


目录

1.注意

2.更换国内源

3.设置/home文件夹下为英文

4.禁用Nouveau驱动

5.安装Nvidia驱动(有可能会损坏系统,如果损坏可以重装并看看网上的其他教程,除了这种安装方法还有其他安装方法,自行上网了解)

6.cuda安装:

7.cudnn安装:

8.安装ROS(有些图忘记截了)

9.安装opencv-3.4.16和opencv_contrib-3.4.16(Ubuntu18.04),Ubuntu20.04请装opencv-4.2.0及其扩展模块:

10.安装protobuf2.6.1

11.配置OpenBLAS

12.配置seetaface2工作空间

13.百度智能云

14.使在桌面上右键打开终端时进入Desktop目录

15.同步双系统时间

16.启动菜单的默认项

17.安装darknet版yolov3及darknet-ros工作空间

18.Azure Kinect SDK-v1.4.0的安装(Ubuntu18.04)

19.配置科大讯飞

20.配置realsense及realsense工作空间

21.配置Kinova机械臂工作空间

22.配置机器人导航(实体)

23.安装配置caffe

24.安装libfreenect2

25.安装vtk8.2.0及PCL1.9.1

26.安装CarlaUE4(必须是Carla的UE仓库里的carla分支才可以通过安装Carla时的编译)

27.安装Carla0.9.13(添加fisheye sensor模块)


本文所有用到的文件打包供大家下载(不含代码){Updating}:

链接:

https://pan.baidu.com/s/1PgmWHKl8oyX_cWYx_uZJrg?pwd=zwz4

提取码:

zwz4
--来自百度网盘超级会员v4的分享

1.注意

刚进入系统一段时间,系统会通知更新到新版本系统(Ubuntu18.04),选择否,之后会询问是否更新系统组件(大概400mb),选择是。

阻止软件更新弹窗:

打开终端输入:

sudo chmod a-x /usr/bin/update-notifier

将关机时间从90秒换为5秒:

打开终端输入:

sudo gedit /etc/systemd/system.conf

 将:

#DefaultTimeoutStopSec=90s

改为:

DefaultTimeoutStopSec=5s

 保存退出,打开终端输入:

sudo systemctl daemon-reload

打开终端输入:

sudo gedit ~/.bashrc
  1. # 找到以下代码段,修改如下:
  2. if [ "$color_prompt" = yes ]; then
  3. #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
  4. PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w$(git_branch)\[\033[00m\]\$ '
  5. else
  6. #PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
  7. PS1='${debian_chroot:+($debian_chroot)}\u@\h:\W$(git_branch)\$ '
  8. fi
  9. # 在最后加入如下代码段:
  10. git_branch()
  11. {
  12. branch=`git rev-parse --abbrev-ref HEAD 2>/dev/null`
  13. if [ "${branch}" != "" ]
  14. then
  15. if [ "${branch}" = "(no branch)" ]
  16. then
  17. branch="(`git rev-parse --short HEAD`...)"
  18. fi
  19. #echo -e " \033[01;36m[$branch]\033[0m " # 天蓝色字体
  20. #echo -e " \033[46;37m[$branch]\033[0m " # 天蓝色背景,白色字体
  21. echo -e " \033[1;43;37m[$branch]\033[0m " # 黄色背景,白色字体
  22. fi
  23. }

之后保存退出

source ~/.bashrc

 这样就可以更清晰的显示git分支~

2.更换国内源

sudo gedit /etc/apt/sources.list

 将原本的注释掉,在最下方加入:

# 中科大源(Ubuntu 18.04)

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse

## Not recommended
# deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

# 中科大源(Ubuntu 20.04)
deb https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse

deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse

deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse

deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse

## Not recommended
# deb https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse

或(寻找属于自己的发行版):

https://mirrors.ustc.edu.cn/repogen/icon-default.png?t=N7T8https://mirrors.ustc.edu.cn/repogen/

sudo apt-get update

 anaconda镜像源(~/.condarc):

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  deepmodeling: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/
  nvidia: https://mirrors.cernet.edu.cn/anaconda-extra/cloud/
envs_dirs:
  - /home/m0rtzz/Program_Files/anaconda3/envs

3.设置/home文件夹下为英文

export LANG=en_US
xdg-user-dirs-gtk-update

​编辑选择右边的Update Names

11860bd995624609b10076f25fc108fb.png

 之后执行以下语句:

export LANG=zh_CN
reboot

勾选不要在次询问我,并选择保留旧的名称

560bffa1f8fd4255a9bec1f2be43efcd.png

4.禁用Nouveau驱动

sudo gedit /etc/modprobe.d/blacklist.conf

输入

  1. blacklist nouveau
  2. options nouveau modeset=0

保存后关闭,打开终端,输入:

sudo update-initramfs -u
reboot

5.安装Nvidia驱动(有可能会损坏系统,如果损坏可以重装并看看网上的其他教程,除了这种安装方法还有其他安装方法,自行上网了解)

打开终端,输入:

sudo apt-get install gcc g++ make
sudo ubuntu-drivers devices

15997876f01749bfa95298efd251fcd1.png

 寻找带有recommended的版本,输入

sudo apt-get install nvidia-driver-* nvidia-settings nvidia-prime

(*是你的版本号)

sudo apt-get update
sudo apt-get upgrade
reboot

 验证版本

nvidia-smi

3edc9839576e4b20a1e95a852e80d8e4.png

6.cuda安装:

https://developer.nvidia.com/cuda-toolkit-archiveicon-default.png?t=N7T8https://developer.nvidia.com/cuda-toolkit-archive

选择和上一步nvidia-smi显示的cuda版本对应的进行安装,官方有教程

安装好之后打开终端输入

sudo gedit ~/.bashrc

 在最后输入

  1. #cuda
  2. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
  3. export PATH=$PATH:/usr/local/cuda/bin
  4. export CUDA_HOME=/usr/local/cuda #cuda的软连接库,可以设置多版本共存指向

保存后关闭,打开终端,输入: 

source ~/.bashrc
sudo gedit /etc/profile

 在最后加入

  1. #cuda
  2. export PATH=/usr/local/cuda/bin:$PATH
  3. export PATH=/usr/local/cuda/bin:$PATH

保存后关闭,打开终端,输入: 

 source /etc/profile

  验证cuda版本

nvcc -V

 91fd7494b10a420ba9cd584fc7abcc8f.png

 安装成功!

7.cudnn安装:

cuDNN Archive | NVIDIA DeveloperExplore and download past releases from cuDNN GPU-accelerated primitive library for deep neural networks.icon-default.png?t=N7T8https://developer.nvidia.com/rdp/cudnn-archive

同样需要选择与刚才安装cuda对应的版本下载,下载好后进入文件所在目录打开终端

tar -xvf cudnn-*-linux-x64-*.tgz 

打开终端:

  1. sudo cp -r cuda/include/* /usr/local/cuda/include/
  2. sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
  1. sudo chmod a+r /usr/local/cuda/include/cudnn.h
  2. sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
  1. sudo ln -sf /usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.0.1 /usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_adv_train.so.8
  2. sudo ln -sf /usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.0.1 /usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8
  3. sudo ln -sf /usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.0.1 /usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8
  4. sudo ln -sf /usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.0.1 /usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8
  5. sudo ln -sf /usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.0.1 /usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_ops_train.so.8
  6. sudo ln -sf /usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.0.1 /usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8
  7. sudo ln -sf /usr/local/cuda-11.4/lib64/libcudnn.so.8 /usr/local/cuda-11.4/lib64/libcudnn.so.8.2.2

 验证是否安装成功

cat /usr/local/cuda/include/cudnn_version.h

 7b37c756e39f4137941bd046fe2fe661.png

8.安装ROS(有些图忘记截了)

设置中科大源

sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'

设置公钥

sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
sudo apt install ros-melodic-desktop-full
  1. echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
  2. source ~/.bashrc
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
sudo apt-get install python3-pip 

 使用阿里镜像源加速pip下载:

sudo pip3 install rosdepc -i https://mirrors.aliyun.com/pypi/simple/
  1. sudo rosdepc init
  2. rosdepc update
sudo chmod 777 -R ~/.ros/ 
roscore

52b0561164a34d3ea62b74322abe50bc.png

   再新建两个终端,分别输入

rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key

 在rosrun turtlesim turtle_teleop_key所在终端点击一下任意位置,然后使用↕↔小键盘控制,看小海龟会不会动,如果会动则安装成功

c40128bd8c5245a48d386c21ba465449.png

9.安装opencv-3.4.16和opencv_contrib-3.4.16(Ubuntu18.04),Ubuntu20.04请装opencv-4.2.0及其扩展模块:

虽然使用cv_bridge时某些shared object有可能和ROS自带的opencv-3.2.0版本冲突,但实测安装3.2.0对cuda的兼容性太差导致无法使用深度相机,所以安装官网最近更新过的OpenCV3.4.16

 经尝试多版本Ubuntu和OpenCV,装Ubuntu20.04,ROS noetic和OpenCV4.2.0及其扩展模块才能解决将彩色图像转换为网络所需的输入Blob后前馈时抛出的(raised OpenCV exception,error: (-215:Assertion failed)等等)。

git clone -b 3.4.16 https://gitee.com/KylenWrt/opencv.git opencv-3.4.16
cd opencv-3.4.16
git clone -b 3.4.16 https://gitee.com/zsy26226/opencv_contrib.git opencv_contrib-3.4.16

  安装所需依赖库,打开终端,输入:

  1. sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
  2. sudo apt update
  3. sudo apt install libjasper1 libjasper-dev
sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev liblapacke-dev checkinstall
sudo apt-get install liblapacke-dev checkinstall

进入opencv-3.4.16文件夹,打开终端,输入:

mkdir build
cd build

 接下来编译安装,注意此命令的OPENCV_EXTRA_MODULES_PATH=后边的路径是你电脑下的绝对路径,请自行修改

cmake -D CMAKE_BUILD_TYPE=RELEASE -D WITH_GTK_2_X=ON -D OPENCV_ENABLE_NONFREE=ON -D OPENCV_GENERATE_PKGCONFIG=YES -D OPENCV_EXTRA_MODULES_PATH=/home/m0rtzz/Program_Files/opencv-3.4.16/opencv_contrib-3.4.16/modules -D WITH_CUDA=ON -D WITH_CUDNN=ON -D WITH_FFMPEG=ON -D WITH_OPENGL=ON -D WITH_NVCUVID=ON -D -DENABLE_PRECOMPILED_HEADERS=OFF -D CMAKE_EXE_LINKER_FLAGS=-lcblas -DWITH_LAPACK=OFF -j16 ..

过程中会出现IPPICV: Download: ippicv_2020_lnx_intel64_20191018_general.tgz

 解决方法:

cd ../ && mkdir downloads 
cd downloads && pwd

 复制绝对路径后:

打开这个ippicv.cmake

 把绝对路径复制进去:

 然后把下面网址下载的文件cp进去就行了(或者开头百度云分享链接中自取~)

https://github.com/opencv/opencv_3rdparty/blob/ippicv/master_20191018/ippicv/ippicv_2020_lnx_intel64_20191018_general.tgzicon-default.png?t=N7T8https://github.com/opencv/opencv_3rdparty/blob/ippicv/master_20191018/ippicv/ippicv_2020_lnx_intel64_20191018_general.tgz之后重新打开终端,输入:cmake(别忘了改路径):

cmake -D CMAKE_BUILD_TYPE=RELEASE -D WITH_GTK_2_X=ON -D OPENCV_ENABLE_NONFREE=ON -D OPENCV_GENERATE_PKGCONFIG=YES -D OPENCV_EXTRA_MODULES_PATH=/home/m0rtzz/Program_Files/opencv-3.4.16/opencv_contrib-3.4.16/modules -D WITH_CUDA=ON -D WITH_CUDNN=ON -D WITH_FFMPEG=ON -D WITH_OPENGL=ON -D WITH_NVCUVID=ON -D -DENABLE_PRECOMPILED_HEADERS=OFF -D CMAKE_EXE_LINKER_FLAGS=-lcblas -DWITH_LAPACK=OFF -j16 ..

这些.i文件需要在国外下载,网上说下载好文件直接把他们放进相对应的目录下就行,实测不行(建议科学的上网,想试试网上说法的:

Reference:fatal error: boostdesc_bgm.i: No such file or directory_"atal error: boostdesc_bgm.i: no such file or dire_eziaowonder的博客-CSDN博客OpenCV4 编译 fatal error: boostdesc_bgm.i: No such file or directory环境编译参考错误原因数据参考环境硬件:树莓派 4B 4G系统:RasberryPi OS编译参考Raspberry pi 树莓派安装 OpenCV 4.1.2子豪兄教你在树莓派上安装OpenCV错误编译到 83% 左右的时候出现类似下图的错误(当时没截图,用 #1301 的部分出错报告)[ 80%] Building CXX object modules/xfhttps://blog.csdn.net/curious_undergather/article/details/111639199?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522167905082916800184134715%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=167905082916800184134715&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~rank_v31_ecpm-1-111639199-null-null.blog_rank_default&utm_term=boosetdesc_bgm.i&spm=1018.2226.3001.4450 文件的话,开头百度云分享链接里都有)

cmake -D CMAKE_BUILD_TYPE=RELEASE -D WITH_GTK_2_X=ON -D OPENCV_ENABLE_NONFREE=ON -D OPENCV_GENERATE_PKGCONFIG=YES -D OPENCV_EXTRA_MODULES_PATH=/home/m0rtzz/Program_Files/opencv-3.4.16/opencv_contrib-3.4.16/modules -D WITH_CUDA=ON -D WITH_CUDNN=ON -D WITH_FFMPEG=ON -D WITH_OPENGL=ON -D WITH_NVCUVID=ON -D -DENABLE_PRECOMPILED_HEADERS=OFF -D CMAKE_EXE_LINKER_FLAGS=-lcblas -DWITH_LAPACK=OFF -j16 ..

sudo make -j16

打开那个头文件,把报错所在行改为:

#include "lapacke.h"
sudo make -j16

sudo make install

sudo gedit /etc/ld.so.conf.d/opencv.conf

  加入

/usr/local/lib

保存后关闭,打开终端,输入: 

sudo ldconfig
sudo gedit /etc/bash.bashrc

加入

  1. PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
  2. export PKG_CONFIG_PATH

保存后关闭,打开终端,输入: 

source /etc/bash.bashrc

测试

  1. cd ../samples/cpp/example_cmake
  2. cmake -j8 .
  3. sudo make -j8
  4. ./opencv_example

1cb714361c874eacb01f3bce3f37e1fb.png

安装成功!

设置cv_bridge的版本:

sudo gedit /opt/ros/melodic/share/cv_bridge/cmake/cv_bridgeConfig.cmake
  1. # generated from catkin/cmake/template/pkgConfig.cmake.in
  2. # append elements to a list and remove existing duplicates from the list
  3. # copied from catkin/cmake/list_append_deduplicate.cmake to keep pkgConfig
  4. # self contained
  5. macro(_list_append_deduplicate listname)
  6. if(NOT "${ARGN}" STREQUAL "")
  7. if(${listname})
  8. list(REMOVE_ITEM ${listname} ${ARGN})
  9. endif()
  10. list(APPEND ${listname} ${ARGN})
  11. endif()
  12. endmacro()
  13. # append elements to a list if they are not already in the list
  14. # copied from catkin/cmake/list_append_unique.cmake to keep pkgConfig
  15. # self contained
  16. macro(_list_append_unique listname)
  17. foreach(_item ${ARGN})
  18. list(FIND ${listname} ${_item} _index)
  19. if(_index EQUAL -1)
  20. list(APPEND ${listname} ${_item})
  21. endif()
  22. endforeach()
  23. endmacro()
  24. # pack a list of libraries with optional build configuration keywords
  25. # copied from catkin/cmake/catkin_libraries.cmake to keep pkgConfig
  26. # self contained
  27. macro(_pack_libraries_with_build_configuration VAR)
  28. set(${VAR} "")
  29. set(_argn ${ARGN})
  30. list(LENGTH _argn _count)
  31. set(_index 0)
  32. while(${_index} LESS ${_count})
  33. list(GET _argn ${_index} lib)
  34. if("${lib}" MATCHES "^(debug|optimized|general)$")
  35. math(EXPR _index "${_index} + 1")
  36. if(${_index} EQUAL ${_count})
  37. message(FATAL_ERROR "_pack_libraries_with_build_configuration() the list of libraries '${ARGN}' ends with '${lib}' which is a build configuration keyword and must be followed by a library")
  38. endif()
  39. list(GET _argn ${_index} library)
  40. list(APPEND ${VAR} "${lib}${CATKIN_BUILD_CONFIGURATION_KEYWORD_SEPARATOR}${library}")
  41. else()
  42. list(APPEND ${VAR} "${lib}")
  43. endif()
  44. math(EXPR _index "${_index} + 1")
  45. endwhile()
  46. endmacro()
  47. # unpack a list of libraries with optional build configuration keyword prefixes
  48. # copied from catkin/cmake/catkin_libraries.cmake to keep pkgConfig
  49. # self contained
  50. macro(_unpack_libraries_with_build_configuration VAR)
  51. set(${VAR} "")
  52. foreach(lib ${ARGN})
  53. string(REGEX REPLACE "^(debug|optimized|general)${CATKIN_BUILD_CONFIGURATION_KEYWORD_SEPARATOR}(.+)$" "\\1;\\2" lib "${lib}")
  54. list(APPEND ${VAR} "${lib}")
  55. endforeach()
  56. endmacro()
  57. if(cv_bridge_CONFIG_INCLUDED)
  58. return()
  59. endif()
  60. set(cv_bridge_CONFIG_INCLUDED TRUE)
  61. # set variables for source/devel/install prefixes
  62. if("FALSE" STREQUAL "TRUE")
  63. set(cv_bridge_SOURCE_PREFIX /tmp/binarydeb/ros-melodic-cv-bridge-1.13.1)
  64. set(cv_bridge_DEVEL_PREFIX /tmp/binarydeb/ros-melodic-cv-bridge-1.13.1/.obj-x86_64-linux-gnu/devel)
  65. set(cv_bridge_INSTALL_PREFIX "")
  66. set(cv_bridge_PREFIX ${cv_bridge_DEVEL_PREFIX})
  67. else()
  68. set(cv_bridge_SOURCE_PREFIX "")
  69. set(cv_bridge_DEVEL_PREFIX "")
  70. set(cv_bridge_INSTALL_PREFIX /opt/ros/melodic)
  71. set(cv_bridge_PREFIX ${cv_bridge_INSTALL_PREFIX})
  72. endif()
  73. # warn when using a deprecated package
  74. if(NOT "" STREQUAL "")
  75. set(_msg "WARNING: package 'cv_bridge' is deprecated")
  76. # append custom deprecation text if available
  77. if(NOT "" STREQUAL "TRUE")
  78. set(_msg "${_msg} ()")
  79. endif()
  80. message("${_msg}")
  81. endif()
  82. # flag project as catkin-based to distinguish if a find_package()-ed project is a catkin project
  83. set(cv_bridge_FOUND_CATKIN_PROJECT TRUE)
  84. # if(NOT "include;/usr/include;/usr/include/opencv " STREQUAL " ")
  85. # set(cv_bridge_INCLUDE_DIRS "")
  86. # set(_include_dirs "include;/usr/include;/usr/include/opencv")
  87. if(NOT "include;/usr/local/include/opencv;/usr/local/include/opencv2 " STREQUAL " ")
  88. set(cv_bridge_INCLUDE_DIRS "")
  89. set(_include_dirs "include;/usr/local/include/opencv;/usr/local/include/opencv;/usr/local/include/;/usr/include")
  90. if(NOT "https://github.com/ros-perception/vision_opencv/issues " STREQUAL " ")
  91. set(_report "Check the issue tracker 'https://github.com/ros-perception/vision_opencv/issues' and consider creating a ticket if the problem has not been reported yet.")
  92. elseif(NOT "http://www.ros.org/wiki/cv_bridge " STREQUAL " ")
  93. set(_report "Check the website 'http://www.ros.org/wiki/cv_bridge' for information and consider reporting the problem.")
  94. else()
  95. set(_report "Report the problem to the maintainer 'Vincent Rabaud <vincent.rabaud@gmail.com>' and request to fix the problem.")
  96. endif()
  97. foreach(idir ${_include_dirs})
  98. if(IS_ABSOLUTE ${idir} AND IS_DIRECTORY ${idir})
  99. set(include ${idir})
  100. elseif("${idir} " STREQUAL "include ")
  101. get_filename_component(include "${cv_bridge_DIR}/../../../include" ABSOLUTE)
  102. if(NOT IS_DIRECTORY ${include})
  103. message(FATAL_ERROR "Project 'cv_bridge' specifies '${idir}' as an include dir, which is not found. It does not exist in '${include}'. ${_report}")
  104. endif()
  105. else()
  106. message(FATAL_ERROR "Project 'cv_bridge' specifies '${idir}' as an include dir, which is not found. It does neither exist as an absolute directory nor in '\${prefix}/${idir}'. ${_report}")
  107. endif()
  108. _list_append_unique(cv_bridge_INCLUDE_DIRS ${include})
  109. endforeach()
  110. endif()
  111. # set(libraries "cv_bridge;/usr/lib/x86_64-linux-gnu/libopencv_core.so.3.2.0;/usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.3.2.0;/usr/lib/x86_64-linux-gnu/libopencv_imgcodecs.so.3.2.0")
  112. set(libraries "cv_bridge;/usr/local/lib/libopencv_core.so.3.4.16;/usr/local/lib/libopencv_imgproc.so.3.4.16;/usr/local/lib/libopencv_imgcodecs.so.3.4.16")
  113. foreach(library ${libraries})
  114. # keep build configuration keywords, target names and absolute libraries as-is
  115. if("${library}" MATCHES "^(debug|optimized|general)$")
  116. list(APPEND cv_bridge_LIBRARIES ${library})
  117. elseif(${library} MATCHES "^-l")
  118. list(APPEND cv_bridge_LIBRARIES ${library})
  119. elseif(${library} MATCHES "^-")
  120. # This is a linker flag/option (like -pthread)
  121. # There's no standard variable for these, so create an interface library to hold it
  122. if(NOT cv_bridge_NUM_DUMMY_TARGETS)
  123. set(cv_bridge_NUM_DUMMY_TARGETS 0)
  124. endif()
  125. # Make sure the target name is unique
  126. set(interface_target_name "catkin::cv_bridge::wrapped-linker-option${cv_bridge_NUM_DUMMY_TARGETS}")
  127. while(TARGET "${interface_target_name}")
  128. math(EXPR cv_bridge_NUM_DUMMY_TARGETS "${cv_bridge_NUM_DUMMY_TARGETS}+1")
  129. set(interface_target_name "catkin::cv_bridge::wrapped-linker-option${cv_bridge_NUM_DUMMY_TARGETS}")
  130. endwhile()
  131. add_library("${interface_target_name}" INTERFACE IMPORTED)
  132. if("${CMAKE_VERSION}" VERSION_LESS "3.13.0")
  133. set_property(
  134. TARGET
  135. "${interface_target_name}"
  136. APPEND PROPERTY
  137. INTERFACE_LINK_LIBRARIES "${library}")
  138. else()
  139. target_link_options("${interface_target_name}" INTERFACE "${library}")
  140. endif()
  141. list(APPEND cv_bridge_LIBRARIES "${interface_target_name}")
  142. elseif(TARGET ${library})
  143. list(APPEND cv_bridge_LIBRARIES ${library})
  144. elseif(IS_ABSOLUTE ${library})
  145. list(APPEND cv_bridge_LIBRARIES ${library})
  146. else()
  147. set(lib_path "")
  148. set(lib "${library}-NOTFOUND")
  149. # since the path where the library is found is returned we have to iterate over the paths manually
  150. foreach(path /opt/ros/melodic/lib;/opt/ros/melodic/lib)
  151. find_library(lib ${library}
  152. PATHS ${path}
  153. NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
  154. if(lib)
  155. set(lib_path ${path})
  156. break()
  157. endif()
  158. endforeach()
  159. if(lib)
  160. _list_append_unique(cv_bridge_LIBRARY_DIRS ${lib_path})
  161. list(APPEND cv_bridge_LIBRARIES ${lib})
  162. else()
  163. # as a fall back for non-catkin libraries try to search globally
  164. find_library(lib ${library})
  165. if(NOT lib)
  166. message(FATAL_ERROR "Project '${PROJECT_NAME}' tried to find library '${library}'. The library is neither a target nor built/installed properly. Did you compile project 'cv_bridge'? Did you find_package() it before the subdirectory containing its code is included?")
  167. endif()
  168. list(APPEND cv_bridge_LIBRARIES ${lib})
  169. endif()
  170. endif()
  171. endforeach()
  172. set(cv_bridge_EXPORTED_TARGETS "")
  173. # create dummy targets for exported code generation targets to make life of users easier
  174. foreach(t ${cv_bridge_EXPORTED_TARGETS})
  175. if(NOT TARGET ${t})
  176. add_custom_target(${t})
  177. endif()
  178. endforeach()
  179. set(depends "rosconsole;sensor_msgs")
  180. foreach(depend ${depends})
  181. string(REPLACE " " ";" depend_list ${depend})
  182. # the package name of the dependency must be kept in a unique variable so that it is not overwritten in recursive calls
  183. list(GET depend_list 0 cv_bridge_dep)
  184. list(LENGTH depend_list count)
  185. if(${count} EQUAL 1)
  186. # simple dependencies must only be find_package()-ed once
  187. if(NOT ${cv_bridge_dep}_FOUND)
  188. find_package(${cv_bridge_dep} REQUIRED NO_MODULE)
  189. endif()
  190. else()
  191. # dependencies with components must be find_package()-ed again
  192. list(REMOVE_AT depend_list 0)
  193. find_package(${cv_bridge_dep} REQUIRED NO_MODULE ${depend_list})
  194. endif()
  195. _list_append_unique(cv_bridge_INCLUDE_DIRS ${${cv_bridge_dep}_INCLUDE_DIRS})
  196. # merge build configuration keywords with library names to correctly deduplicate
  197. _pack_libraries_with_build_configuration(cv_bridge_LIBRARIES ${cv_bridge_LIBRARIES})
  198. _pack_libraries_with_build_configuration(_libraries ${${cv_bridge_dep}_LIBRARIES})
  199. _list_append_deduplicate(cv_bridge_LIBRARIES ${_libraries})
  200. # undo build configuration keyword merging after deduplication
  201. _unpack_libraries_with_build_configuration(cv_bridge_LIBRARIES ${cv_bridge_LIBRARIES})
  202. _list_append_unique(cv_bridge_LIBRARY_DIRS ${${cv_bridge_dep}_LIBRARY_DIRS})
  203. list(APPEND cv_bridge_EXPORTED_TARGETS ${${cv_bridge_dep}_EXPORTED_TARGETS})
  204. endforeach()
  205. set(pkg_cfg_extras "cv_bridge-extras.cmake")
  206. foreach(extra ${pkg_cfg_extras})
  207. if(NOT IS_ABSOLUTE ${extra})
  208. set(extra ${cv_bridge_DIR}/${extra})
  209. endif()
  210. include(${extra})
  211. endforeach()

opencv-3.4.4cmake命令:

cmake -D CMAKE_BUILD_TYPE=BUILD -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_GTK_2_X=ON -D OPENCV_ENABLE_NONFREE=ON -D OPENCV_GENERATE_PKGCONFIG=YES -D OPENCV_EXTRA_MODULES_PATH=/home/m0rtzz/Program_Files/opencv-3.4.4/opencv_contrib-3.4.4/modules -D WITH_CUDA=ON -D WITH_CUDNN=ON -D WITH_FFMPEG=ON -D WITH_OPENGL=ON -D WITH_NVCUVID=ON -D -DENABLE_PRECOMPILED_HEADERS=OFF -D CMAKE_EXE_LINKER_FLAGS=-lcblas -DWITH_LAPACK=OFF -D WITH_OPENMP=ON  -D BUILD_TESTS=OFF -D WITH_OPENGL=ON -D BUILD_opencv_xfeatures2d=ON -D CUDA_nppicom_LIBRARY=stdc++ -DENABLE_PRECOMPILED_HEADERS=OFF -DENABLE_PRECOMPILED_HEADERS=OFF -D CUDA_ARCH_BIN=8.6 -D CUDA_nppicom_LIBRARY=stdc++ -D CUDA_GENERATION=Auto -D CUDA_HOST_COMPILER:FILEPATH=/usr/bin/gcc-7 -j16 ..

opencv-4.2.0cmake命令(Ubuntu20.04装这个): 

cmake -D CMAKE_BUILD_TYPE=RELEASE -D OPENCV_GENERATE_PKGCONFIG=ON -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=/home/m0rtzz/Program_Files/opencv-4.2.0/opencv_contrib-4.2.0/modules -D WITH_V4L=ON -D WITH_QT=ON -D WITH_GTK=ON -D WITH_VTK=ON -D WITH_OPENGL=ON -D WITH_OPENMP=ON -D BUILD_EXAMPLES=ON -D WITH_CUDA=ON -D WITH_CUDNN=ON -D BUILD_TIFF=ON -D ENABLE_PRECOMPILED_HEADERS=OFF -D OPENCV_ENABLE_NONFREE=ON -D CUDA_GENERATION=Auto -D CUDA_CUDA_LIBRARY=/usr/local/cuda-11.7/lib64/stubs/libcuda.so -D CUDA_TOOLKIT_ROOT_DIR=0 -D CUDNN_LIBRARY=/usr/local/cuda-11.7/lib64/libcudnn.so -D WITH_ADE=OFF ..

或:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D OPENCV_GENERATE_PKGCONFIG=ON -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=/home/m0rtzz/Program_Files/opencv-4.2.0/opencv_contrib-4.2.0/modules -D WITH_V4L=ON -D WITH_QT=ON -D WITH_GTK=ON -D WITH_VTK=ON -D WITH_OPENGL=ON -D WITH_OPENMP=ON -D BUILD_EXAMPLES=ON -D WITH_CUDA=ON -D WITH_CUDNN=ON -D BUILD_TIFF=ON -D ENABLE_PRECOMPILED_HEADERS=OFF -D OPENCV_ENABLE_NONFREE=ON -D CUDA_GENERATION=Auto -D WITH_ADE=OFF CUDA_CUDA_LIBRARY=true -D CUDA_nppicom_LIBRARY=true -j16 ..

 或:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D OPENCV_GENERATE_PKGCONFIG=ON -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=/home/m0rtzz/Program_Files/opencv-4.2.0/opencv_contrib-4.2.0/modules -D WITH_V4L=ON -D WITH_QT=ON -D WITH_GTK=ON -D WITH_VTK=OFF -D WITH_OPENGL=ON -D WITH_OPENMP=ON -D BUILD_EXAMPLES=ON -D WITH_CUDA=ON -D WITH_CUDNN=ON -D BUILD_TIFF=ON -D ENABLE_PRECOMPILED_HEADERS=OFF -D OPENCV_ENABLE_NONFREE=ON -D CUDA_GENERATION=Auto -D WITH_ADE=OFF CUDA_CUDA_LIBRARY=true -D CUDNN_LIBRARY=/usr/local/cuda-11.8/lib64/libcudnn.so  -DCUDA_ARCH_BIN=Auto CUDA_ARCH_BIN=8.6 -D CUDA_nppicom_LIBRARY=stdc++ -D CUDA_GENERATION=Auto -D CUDA_HOST_COMPILER:FILEPATH=/usr/bin/gcc -j16 ..

+(解决CUDNN8.x编译报错)

https://github.com/opencv/opencv/pull/17685/filesicon-default.png?t=N7T8https://github.com/opencv/opencv/pull/17685/files如果不执行以下几步,编译darknet_ros会报错:error:‘IplImage’之类的

sudo cp /usr/local/lib/pkgconfig/opencv4.pc /usr/lib/pkgconfig
  1. cd /usr/lib/pkgconfig
  2. sudo mv opencv4.pc opencv.pc

10.安装protobuf2.6.1

sudo apt-get install libtool

https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gzicon-default.png?t=N7T8https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz或镜像:

wget https://gitee.com/M0rtzz/protobuf-2.6.1/raw/master/protobuf-2.6.1.tar.gz

解压压缩包后进入文件夹,打开终端,输入:

./autogen.sh

da01acbb001f42cea9ca08ddad814655.png

./configure --prefix=/usr/local/protobuf 

1c6a5408dece4f7aa5fb4e78680eb913.png

sudo make -j16

140562b609004503a731358eea387731.png

 养成make check 的好习惯

sudo make check -j16

f9827d81f7f946d8ba91d26494c7251d.png

 sudo make install

bf530b0ab13e4939bd810d4731e2764d.png

sudo gedit /etc/profile

在最后加入:

  1. #protobuf
  2. export PATH=$PATH:/usr/local/protobuf/bin/
  3. export PKG_CONFIG_PATH=/usr/local/protobuf/lib/pkgconfig/

保存后关闭,打开终端,输入: 

source /etc/profile
sudo gedit /etc/ld.so.conf

在最后一行输入:

/usr/local/protobuf/lib

保存后关闭,打开终端,输入: 

sudo ldconfig

d80cbadb617b4986a99827d13170e9eb.png

最后验证版本:

protoc --version

11.配置OpenBLAS

sudo apt-get install gcc-arm-linux-gnueabihf libnewlib-arm-none-eabi libc6-dev-i386

OpenBLAS文件夹最上方百度网盘里有,或者绕开github用gitee进行克隆:

git clone https://gitee.com/HyperChao/OpenBLAS.git OpenBLAS
cd OpenBLAS
sudo apt-get install gfortran
sudo make FC=gfortran TARGET=ARMV8 -j16
sudo make PREFIX=/usr/local install

af045e49e18643d8a1c0c12deb166d44.png

 查看版本

grep OPENBLAS_VERSION /usr/local/include/openblas_config.h 

e76d37851f2e4d08b08c4ac035423cbc.png

12.配置seetaface2工作空间

sudo gedit ~/.bashrc

 在最后加入

source /home/m0rtzz/Workspaces/catkin_ws/devel/setup.bash

保存后关闭,打开终端,输入:  

source ~/.bashrc

597806c7f0834400b846b99cae4c9d63.png

0bccdd5c978048189fcd47437ad89dfc.png

解决办法:

终端输入: 

sudo gedit ~/.bashrc

加入工作空间下lib文件夹的路径

export LD_LIBRARY_PATH=/home/m0rtzz/Workspaces/catkin_ws/lib:$LD_LIBRARY_PATH

保存后关闭,打开终端,输入:  

source ~/.bashrc

4000fa5374ee48dfbc2fdee5c5ddf2d0.png

 解决!

报错:

Gtk-Message: 15:22:30.610: Failed to load module "canberra-gtk-module"

下方第16小节最后有解决办法~

13.百度智能云

sudo apt-get install curl

include jsoncpp库的头文件改为

 #include "jsoncpp/json/json.h"

g++编译

g++ *.cpp -o * -lcurl -ljsoncpp

 运行

./*

14.使在桌面上右键打开终端时进入Desktop目录

Ubuntu – Details of source package gnome-terminal in bionicicon-default.png?t=N7T8https://packages.ubuntu.com/source/bionic/gnome-terminal

下载下图表格中的下边两个文件

ae94b3493cf44d08a7a962e070256653.png

 下载好gnome-terminal_3.28.1.orig.tar.xz文件之后解压出一个文件夹gnome-terminal-3.28.1,将gnome-terminal_3.28.1-1ubuntu1.debian.tar.xz 里面debian目录下的文件解压到之前解压出的gnome-terminal-3.28.1目录下


5097eb7f2b8b474a8411cf11a3694b55.png

在此目录下打开终端

git apply patches/*.patch

安装依赖

sudo apt install  intltool  libvte-2.91-dev gsettings-desktop-schemas-dev uuid-dev libdconf-dev libpcre2-dev libgconf2-dev libxml2-utils  gnome-shell libnautilus-extension-dev itstool  yelp-tools pcre2-utils

 打开src/下的terminal-nautilus.c

找到

  1. static inline gboolean
  2. desktop_opens_home_dir (TerminalNautilus *nautilus)
  3. {
  4. #if 0
  5. return _client_get_bool (gconf_client,
  6. "/apps/nautilus-open-terminal/desktop_opens_home_dir",
  7. NULL);
  8. #endif
  9. return TRUE;
  10. }

改为

  1. static inline gboolean
  2. desktop_opens_home_dir (TerminalNautilus *nautilus)
  3. {
  4. #if 0
  5. return _client_get_bool (gconf_client,
  6. "/apps/nautilus-open-terminal/desktop_opens_home_dir",
  7. NULL);
  8. #endif
  9. return FALSE;
  10. }

 src下打开终端

cd ..
autoreconf --install
autoconf
./configure --prefix='/usr'
sudo make -j8
sudo make check -j8
sudo make install

83ef9eec20fe4b5991ce5e0d3107d68d.png

reboot

之后在桌面上打开终端,看看是否生效 ,没生效打开终端

sudo cp /usr/lib/nautilus/extensions-3.0/libterminal-nautilus.so /usr/lib/x86_64-linux-gnu/nautilus/extensions-3.0/
reboot

问题解决!

15.同步双系统时间

sudo apt-get install ntpdate
sudo ntpdate time.windows.com
timedatectl set-local-rtc 1 --adjust-system-clock

c17b8bd812df4e5f86bfba16f5948a9d.png

16.启动菜单的默认项

sudo gedit /etc/default/grub

 改一下GRUB_DEFAULT=后边的数字,默认是0,windows是第n个就设置为 n-1

2a4260711db540b6af9fd30682dc9257.png

保存后关闭,打开终端,输入:  

sudo update-grub

cb668a5bf2a84177956f1c6417f5310a.png

reboot

 重启后问题解决~

17.安装darknet版yolov3及darknet-ros工作空间

git clone https://gitcode.net/xyll24/darknet.git darknet
cd darknet
sudo gedit Makefile

 修改以下前几行为:

  1. GPU=1
  2. CUDNN=1
  3. CUDNN_HALF=1
  4. OPENCV=1
  5. AVX=0
  6. OPENMP=1
  7. LIBSO=1
  8. ZED_CAMERA=0
  9. ZED_CAMERA_v2_8=0

 然后修改NVCC=后边为nvcc路径:

NVCC=/usr/local/cuda-11.4/bin/nvcc

d12dd2a5ce1e4ea7b24103796dc07a00.png

 之后保存退出后,打开终端,输入:

sudo gedit /etc/ld.so.conf.d/cuda.conf

 加入以下内容后保存退出:

/usr/local/cuda/lib64

 打开终端输入:

sudo ldconfig
sudo make -j16
./darknet

输出为:

usage: ./darknet <function>

9e10fa48060244c9972d9db1be8178cb.png

 之后我们下载yolov3权重文件:

mkdir weights && cd ./weights && wget https://pjreddie.com/media/files/yolov3.weights 

正常wget太慢,我们使用mwget进行安装:

找一个你想安装mwget的地方打开终端,输入:

sudo apt install build-essential
sudo apt upgrade intltool
sudo apt install  libssl-dev

 之后:

wget http://jaist.dl.sourceforge.net/project/kmphpfm/mwget/0.1/mwget_0.1.0.orig.tar.bz2
tar -xjvf mwget_0.1.0.orig.tar.bz2
cd mwget_0.1.0.orig
./configure
sudo make -j8
sudo make install

 函数报错的话在文件夹中搜索httpplugin.h和ftpplugin.h中加入

#include <string.h>

保存后关闭,打开终端,输入:  

再次安装:

sudo make -j8
sudo make install

 之后mwget就安装成功了

我们用mwget多线程获取权重文件:

cd darknet/ && mkdir weights && cd weights/
mwget https://pjreddie.com/media/files/yolov3.weights -n16

上方命令是16线程获取 ,速度会快很多

05ea3530787d45c1b9672559eb8df952.png

到此为止darknet版yolov3就配置好了

下面我们测试一下:

./darknet detect cfg/yolov3.cfg weights/yolov3.weights data/dog.jpg

 输出以下就证明配置没有问题:

9967309fc02949e98046bf0b4566371b.png

输出的最后一行报错:

Gtk-Message: 15:22:30.610: Failed to load module "canberra-gtk-module"

解决方法:

sudo apt-get install libcanberra-gtk*

 安装之后重新运行就不会报错了。 

配置 darknet-ros工作空间:

mkdir darknet-ros_test_ws && cd darknet-ros_test_ws/ && mkdir src
cd src/ && catkin_init_workspace
cd .. && catkin_make -j16
cd src/
git clone --recursive https://gitee.com/mirrors_leggedrobotics/darknet_ros.git darknet_ros 

 如果是OpenCV4:

  1. git clone -b opencv4 --recursive https://github.com/kunaltyagi/darknet_ros.git darknet_ros
  2. git branch -a
  3. git checkout remotes/origin/opencv4
  4. git submodule update --recursive

  如果是OpenCV4,视频流只有第一帧是RGB8编码格式,阅读源码后发现在show_image之前调用image.cpp中的rgbgr_image函数循环转换图像编码格式即可解决此问题:

  1. // @file : image.cpp
  2. void rgbgr_image(image im)
  3. {
  4. int i;
  5. for(i = 0; i < im.w*im.h; ++i){
  6. float swap = im.data[i];
  7. im.data[i] = im.data[i+im.w*im.h*2];
  8. im.data[i+im.w*im.h*2] = swap;
  9. }
  10. }
  1. // @file : YoloObjectDetector.cpp
  2. void *YoloObjectDetector::displayInThread(void *ptr)
  3. {
  4. // NOTE: Modified by M0rtzz,Solved the problem of displaying video streams as bgr8
  5. rgbgr_image(buff_[(buffIndex_ + 1) % 3]);
  6. int c = show_image(buff_[(buffIndex_ + 1) % 3], "YOLO V3", waitKeyDelay_);
  7. if (c != -1)
  8. c = c % 256;
  9. if (c == 27)
  10. {
  11. demoDone_ = 1;
  12. return 0;
  13. }
  14. else if (c == 82)
  15. {
  16. demoThresh_ += .02;
  17. }
  18. else if (c == 84)
  19. {
  20. demoThresh_ -= .02;
  21. if (demoThresh_ <= .02)
  22. demoThresh_ = .02;
  23. }
  24. else if (c == 83)
  25. {
  26. demoHier_ += .02;
  27. }
  28. else if (c == 81)
  29. {
  30. demoHier_ -= .02;
  31. if (demoHier_ <= .0)
  32. demoHier_ = .0;
  33. }
  34. return 0;
  35. }

  若darknet_ros/darknet文件夹下为空,则:

cd darknet_ros && sudo rm -rf darknet
git clone https://github.com/alexeyab/darknet.git darknet

 catkin_make如果编译不过的话(error: ‘IplImage’之类的,之前装OpenCV提到过避免报错的方法),注意以下命令是只编译darknet-ros一个包,若工作空间下有多个包需要一起编译那么把命令中的darknet-ros删除重新执行即可:

catkin_make -j16 darknet_ros --cmake-args -DCMAKE_CXX_FLAGS=-DCV__ENABLE_C_API_CTORS

 如果报错nvcc fatal : Unsupported gpu architecture 'compute_30'之类的,是因为CUDA11已经不支持compute_30了,我们将darknet_ros/darknet/Makefile和darknet_ros/darknet_ros/CMakeLists.txt中含有 'compute_30'的行进行注释后重新catkin_make:

 

18.Azure Kinect SDK-v1.4.0的安装(Ubuntu18.04)

Reference: BkbK-的博客icon-default.png?t=N7T8https://bokai.blog.csdn.net/article/details/119115883?spm=1001.2014.3001.5502

git clone -b v1.4.0 https://github.com/microsoft/Azure-Kinect-Sensor-SDK.git Azure-Kinect-Sensor-SDK-v1.4.0

 嫌太慢可以使用gitee镜像仓库克隆:

git clone -b v1.4.0 https://gitee.com/javenst/Azure-Kinect-Sensor-SDK.git Azure-Kinect-Sensor-SDK-v1.4.0
sudo dpkg --add-architecture amd64
sudo apt-get update
sudo apt install -y  pkg-config  ninja-build doxygen clang  gcc-multilib  g++-multilib python3 nasm cmake libgl1-mesa-dev libsoundio-dev libvulkan-dev libx11-dev libxcursor-dev libxinerama-dev libxrandr-dev libusb-1.0-0-dev libssl-dev libudev-dev mesa-common-dev uuid-dev

Index of /ubuntu/18.04/prod/pool/main/libk/icon-default.png?t=N7T8https://packages.microsoft.com/ubuntu/18.04/prod/pool/main/libk/

从上面的网站下载 libk4a1.2libk4a1.2_1.2.0_amd64.deb文件

f806a0d411ac415497e78b45bf3c20ac.png

 解压 .deb 文件,再解压内部的 data.tar.gzcontrol.tar.gz文件,并进入data文件夹,打开终端输入:

  1. cd usr/lib/x86_64-linux-gnu
  2. sudo cp libdepthengine.so.2.0 /usr/lib/x86_64-linux-gnu

随后进入下载好的 Azure-Kinect-Sensor-SDK-v1.4.0文件夹下打开终端输入

  1. mkdir build && cd build
  2. cmake -j8 .. -GNinja

注意此步过程中extern/libyuv/src克隆较慢原因是使用了google的网站,我们把对应文件的克隆url改为github的就能正常克隆了,在Azure-Kinect-Sensor-SDK-v1.4.0文件夹下键盘Ctrl+H显示隐藏文件,打开.gitmodules文件,修改libyuv的部分为:

  1. [submodule "extern/libyuv/src"]
  2. path = extern/libyuv/src
  3. url = https://github.com/lemenkov/libyuv.git

保存后关闭

 之后打开.git文件夹下的config文件,修改libyuv的部分为:

  1. [submodule "extern/libyuv/src"]
  2. active = true
  3. url = https://github.com/lemenkov/libyuv.git

接下来就能正常克隆了,但是速度还是很慢,请耐心等待~

保存后关闭,打开终端,输入: 

cmake -j8 .. -GNinja

克隆完成后为如图所示:

b07fac22ae4b45ebb3e5a061739a4d87.png

 之后输入:

sudo ninja -j8

 完成后如下:

c625650ae9744c02aea905984da47566.png

 最后输入:

sudo ninja install

完成后如下:

b71183010a584c469b0a6cbfc72b3e39.png

 之后安装依赖:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo gedit /etc/apt/sources.list

 在最后一行加入:

  1. ##gcc-4.9
  2. deb http://dk.archive.ubuntu.com/ubuntu/ xenial main
  3. deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe
  4. ##

保存后关闭,打开终端,输入:

sudo apt-get update
sudo apt-get install gcc-4.9
sudo apt-get upgrade libstdc++6
sudo cp /usr/lib/x86_64-linux-gnu/libk4a1.4/libdepthengine.so.2.0 /usr/lib

之后测试一下:

sudo ./bin/k4aviewer

 授予权限:

cd ../ && sudo cp scripts/99-k4a.rules /etc/udev/rules.d/.

 Ubuntu20.04,Reference:

https://blog.csdn.net/qq_42108414/article/details/129015474icon-default.png?t=N7T8https://blog.csdn.net/qq_42108414/article/details/129015474

19.配置科大讯飞

SDK下载 - 科大讯飞api接口 - 讯飞开放平台科大讯飞api接口,为开发者免费提供:语音识别、语音合成、语音评测、声纹识别、人脸识别等SDK下载服务,一站式人机智能语音交互等解决方案。icon-default.png?t=N7T8https://www.xfyun.cn/sdk/dispatcher

sudo apt-get install sox libsox-fmt-all pavucontrol
sudo gedit /usr/include/pcl-1.8/pcl/visualization/cloud_viewer.h

修改一下:

  1. //line 199左右
  2. private:
  3. /** \brief Private implementation. */
  4. struct CloudViewer_impl;
  5. //std::auto_ptr<CloudViewer_impl> impl_;
  6. std::shared_ptr<CloudViewer_impl> impl_;
  7. boost::signals2::connection
  8. registerMouseCallback (boost::function<void (const pcl::visualization::MouseEvent&)>);

 下载所需SDK,将libs/x64/libmsc.so文件拷贝至/usr/lib/下;修改~/.bashrc;

  1. cmake_minimum_required(VERSION 3.0.2)
  2. project(tts_voice_test)
  3. SET(CMAKE_CXX_FLAGS "-std=c++0x")
  4. find_package(k4a REQUIRED)
  5. find_package(OpenCV REQUIRED)
  6. find_package(catkin REQUIRED COMPONENTS
  7. roscpp
  8. rospy
  9. std_msgs
  10. cv_bridge
  11. message_generation
  12. )
  13. generate_messages(
  14. DEPENDENCIES
  15. std_msgs
  16. )
  17. include_directories(
  18. ~/Workspaces/tts_test_ws/include
  19. ${catkin_INCLUDE_DIRS}
  20. )
  21. add_executable(tts_voice_test src/tts_voice_test.cpp)
  22. target_link_libraries(tts_voice_test
  23. PRIVATE k4a::k4a
  24. ${OpenCV_LIBRARIES}
  25. ${PCL_LIBRARIES}
  26. ${catkin_LIBRARIES}
  27. ${catkin_LIBRARIES} -lcurl -ljsoncpp -lmsc -lrt -ldl -pthread
  28. ${catkin_LIBRARIES} /home/m0rtzz/Workspaces/tts_voice_test_ws/libs/x64/libmsc.so -ldl -pthread -lasound

打开终端:

catkin_make

若找不到asoundlib.h文件打开终端输入:

sudo apt-get install libasound2-dev

编译通过~

20.配置realsense及realsense工作空间

sudo apt-get install ros-melodic-realsense2-camera ros-melodic-rgbd-launch

808f1ad01090402eafa94dd83545aed3.png

 安装realsense sdk:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE || sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE

8fbc31d16a394fdc91f04302aa04b1d4.png

sudo add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo $(lsb_release -cs) main" -u

344007bb790841da91383d12d7eaa42b.png

sudo apt-get update

 安装realsense lib

sudo apt-get install librealsense2-dkms librealsense2-utils

eaed28f89f1d421ca57b099a6266168a.png

测试:

realsense-viewer

66d6e2234539406982aa1aaad9e82698.png

 下载lib并指定版本为v2.50.0,否则接下来会与realsense-ros版本冲突导致无法打开摄像头:

git clone -b v2.50.0 https://gitee.com/lhospitallky/librealsense.git librealsense-2.50.0

295493ada2824a79bc59561e41fba193.png  安装依赖:

sudo apt-get install libudev-dev pkg-config libgtk-3-dev libusb-1.0-0-dev pkg-config libglfw3-dev

 进入刚才克隆的librealsense文件夹内:

cd librealsense-2.50.0/
./scripts/setup_udev_rules.sh
./scripts/patch-realsense-ubuntu-lts.sh

 注意:上面的命令可能执行过慢,请耐心等待,或者科学的上网~

  完成结果如下:

389a2809970d49d8a24d299ece865576.png

之后输入:

mkdir build && cd build
  1. # @file : CMakeLists.txt
  2. # NOTE: Modified by M0rtzz
  3. LINK_LIBRARIES(-lcurl -lcrypto)
cmake -j8 ../ -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=true

 以下编译过慢,使用CPU最大线程进行make,速度会快很多:

sudo make -j16
sudo make install

测试:

cd examples/capture
./rs-capture

接下来我们配置realsense工作空间:

创建一个realsense_test_ws文件夹,进入文件夹下,打开终端:

mkdir src && cd src/

 下载功能包:

git clone -b ros1-legacy https://gitee.com/joosoo/realsense-ros.git realsense-ros

2c9b3f3767d845dcb4e2ace8830f6d7b.png

cd ..
catkin_make -j16 -DCATKIN_ENABLE_TESTING=False -DCMAKE_BUILD_TYPE=Release
catkin_make install

d66e547ed18645e380ba7beb0fd3c999.png

测试:

roslaunch realsense2_camera rs_camera.launch

d6c0eef6da874de9aff7596e3cc16a86.png

 还没安摄像头~

21.配置Kinova机械臂工作空间

mkdir -p kinova_test_ws/src
cd kinova_test_ws/src 
catkin_init_workspace

645ec87a65914495adcd474cda614d5f.png

cd ..
catkin_make
echo 'source /home/m0rtzz/Workspaces/kinova_test_ws/devel/setup.bash' >> ~/.bashrc
cd src/
git clone https://gitee.com/dva7777/kinova-ros.git kinova-ros
cd ..

安装缺少的moveit中相应的功能包 :

sudo apt-get install ros-melodic-moveit-visual-tools ros-melodic-moveit-ros-planning-interface
catkin_make -j16

0808ea44aa244c66b30562c0307c9594.png

sudo cp src/kinova-ros/kinova_driver/udev/10-kinova-arm.rules /etc/udev/rules.d/

 安装Moveit和pr2:

sudo apt-get install ros-melodic-moveit ros-melodic-trac-ik ros-melodic-pr2*

4c19506aeb7943caa635bc8a9b92cda9.png 完成~

22.配置机器人导航(实体)

安装 Arduino IDE:

https://www.arduino.cc/en/softwareicon-default.png?t=N7T8https://www.arduino.cc/en/software

 下载Linux 64bit安装包

tar -xvf arduino-1.8.19-linux64.tar.xz
sudo mv arduino-1.8.19 /opt
cd /opt/arduino-1.8.19
sudo chmod +x install.sh
sudo ./install.sh
sudo apt install ros-melodic-move-base* ros-melodic-turtlebot3-* ros-melodic-dwa-local-planner
sudo apt-get install ros-melodic-joy ros-melodic-teleop-twist-joy ros-melodic-teleop-twist-keyboard ros-melodic-laser-proc ros-melodic-rgbd-launch ros-melodic-depthimage-to-laserscan ros-melodic-rosserial-arduino ros-melodic-rosserial-python ros-melodic-rosserial-server ros-melodic-rosserial-client ros-melodic-rosserial-msgs ros-melodic-amcl ros-melodic-map-server ros-melodic-move-base ros-melodic-urdf ros-melodic-xacro ros-melodic-compressed-image-transport ros-melodic-rqt-image-view ros-melodic-gmapping ros-melodic-navigation ros-melodic-interactive-markers

 安装 gmapping 包(用于构建地图):

sudo apt-get install ros-melodic-gmapping

安装地图服务包(用于保存与读取地图): 

sudo apt-get install ros-melodic-map-server

安装 navigation 包(用于定位以及路径规划): 

sudo apt-get install ros-melodic-navigation

因tf和tf2迁移问题,需将工作空间内的所有global_costmap_params.yaml和local_costmap_params.yaml文件里的头几行去掉“/”,返回工作空间根目录下重新编译。

Reference:

http://wiki.ros.org/tf2/Migrationicon-default.png?t=N7T8http://wiki.ros.org/tf2/Migration

首先创建实体导航工作空间:

mkdir -p navigation_entity_test_ws/src

e6316e2fe5e941369669b43ab767ea9d.png

cd navigation_entity_test_ws/src
catkin_create_pkg entity_test roscpp rospy std_msgs  gmapping map_server amcl move_base

12f06d657996445fa8d8cac418d21147.png

cd .. && catkin_make

c5a44dee31014fcd9b8f97237e3f58e4.png

 查看一下文件目录,tree命令在下边的PS小节有讲怎么安装

tree .

f5242b23d16a43e88ce2626341f3ed33.png

cd src/ && catkin_create_pkg robot_start_test roscpp rospy std_msgs ros_arduino_python usb_cam rplidar_ros
cd robot_start_test/ && mkdir launch && cd launch && touch start_test.launch
  1. <!--@File Name : start_test.launch
  2. @Brief : 机器人启动文件:
  3. 1.启动底盘
  4. 2.启动激光雷达
  5. 3.启动摄像头
  6. -->
  7. <launch>
  8. <include file="$(find ros_arduino_python)/launch/arduino.launch" />
  9. <include file="$(find usb_cam)/launch/usb_cam-test.launch" />
  10. <include file="$(find rplidar_ros)/launch/rplidar.launch" />
  11. </launch>

FIXME:Updating...

接下来创建机器人模型相关的功能包:

cd src/
catkin_create_pkg robot_description_test urdf xacro

0af4f65dceea471f94be94ef66fadbe2.png

 在功能包下新建 urdf 目录,编写具体的 urdf 文件(code命令是VSCode,没安装的小伙伴下边PS小节有下载网址~):

cd robot_description_test/ && mkdir urdf
cd urdf/ && touch {robot.urdf.xacro,robot_base.urdf.xacro,robot_camera.urdf.xacro,robot_laser.urdf.xacro} && code robot.urdf.xacro

将下列代码粘贴进去:

  1. <!-- File Name : robot.urdf.xacro -->
  2. <robot name="robot_test" xmlns:xacro="http://wiki.ros.org/xacro">
  3. <xacro:include filename="robot_base.urdf.xacro" />
  4. <xacro:include filename="robot_camera.urdf.xacro" />
  5. <xacro:include filename="robot_laser.urdf.xacro" />
  6. </robot>

 保存退出,打开终端输入:

code robot_base.urdf.xacro

将下列代码粘贴进去:

  1. <!-- File Name : robot_base.urdf.xacro -->
  2. <robot name="robot_test" xmlns:xacro="http://wiki.ros.org/xacro">
  3. <xacro:property name="footprint_radius" value="0.001" />
  4. <link name="base_footprint">
  5. <visual>
  6. <geometry>
  7. <sphere radius="${footprint_radius}" />
  8. </geometry>
  9. </visual>
  10. </link>
  11. <xacro:property name="base_radius" value="0.1" />
  12. <xacro:property name="base_length" value="0.08" />
  13. <xacro:property name="lidi" value="0.015" />
  14. <xacro:property name="base_joint_z" value="${base_length / 2 + lidi}" />
  15. <link name="base_link">
  16. <visual>
  17. <geometry>
  18. <cylinder radius="0.1" length="0.08" />
  19. </geometry>
  20. <origin xyz="0 0 0" rpy="0 0 0" />
  21. <material name="baselink_color">
  22. <color rgba="1.0 0.5 0.2 0.5" />
  23. </material>
  24. </visual>
  25. </link>
  26. <joint name="link2footprint" type="fixed">
  27. <parent link="base_footprint" />
  28. <child link="base_link" />
  29. <origin xyz="0 0 0.055" rpy="0 0 0" />
  30. </joint>
  31. <xacro:property name="wheel_radius" value="0.0325" />
  32. <xacro:property name="wheel_length" value="0.015" />
  33. <xacro:property name="PI" value="3.1415927" />
  34. <xacro:property name="wheel_joint_z" value="${(base_length / 2 + lidi - wheel_radius) * -1}" />
  35. <xacro:macro name="wheel_func" params="wheel_name flag">
  36. <link name="${wheel_name}_wheel">
  37. <visual>
  38. <geometry>
  39. <cylinder radius="${wheel_radius}" length="${wheel_length}" />
  40. </geometry>
  41. <origin xyz="0 0 0" rpy="${PI / 2} 0 0" />
  42. <material name="wheel_color">
  43. <color rgba="0 0 0 0.3" />
  44. </material>
  45. </visual>
  46. </link>
  47. <joint name="${wheel_name}2link" type="continuous">
  48. <parent link="base_link" />
  49. <child link="${wheel_name}_wheel" />
  50. <origin xyz="0 ${0.1 * flag} ${wheel_joint_z}" rpy="0 0 0" />
  51. <axis xyz="0 1 0" />
  52. </joint>
  53. </xacro:macro>
  54. <xacro:wheel_func wheel_name="left" flag="1" />
  55. <xacro:wheel_func wheel_name="right" flag="-1" />
  56. <xacro:property name="small_wheel_radius" value="0.0075" />
  57. <xacro:property name="small_joint_z" value="${(base_length / 2 + lidi - small_wheel_radius) * -1}" />
  58. <xacro:macro name="small_wheel_func" params="small_wheel_name flag">
  59. <link name="${small_wheel_name}_wheel">
  60. <visual>
  61. <geometry>
  62. <sphere radius="${small_wheel_radius}" />
  63. </geometry>
  64. <origin xyz="0 0 0" rpy="0 0 0" />
  65. <material name="wheel_color">
  66. <color rgba="0 0 0 0.3" />
  67. </material>
  68. </visual>
  69. </link>
  70. <joint name="${small_wheel_name}2link" type="continuous">
  71. <parent link="base_link" />
  72. <child link="${small_wheel_name}_wheel" />
  73. <origin xyz="${0.08 * flag} 0 ${small_joint_z}" rpy="0 0 0" />
  74. <axis xyz="0 1 0" />
  75. </joint>
  76. </xacro:macro >
  77. <xacro:small_wheel_func small_wheel_name="front" flag="1"/>
  78. <xacro:small_wheel_func small_wheel_name="back" flag="-1"/>
  79. </robot>

  保存退出,打开终端输入:

code robot_camera.urdf.xacro

 将下列代码粘贴进去:

  1. <!-- File Name : robot_camera.urdf.xacro -->
  2. <robot name="robot_test" xmlns:xacro="http://wiki.ros.org/xacro">
  3. <xacro:property name="camera_length" value="0.02" />
  4. <xacro:property name="camera_width" value="0.05" />
  5. <xacro:property name="camera_height" value="0.05" />
  6. <xacro:property name="joint_camera_x" value="0.08" />
  7. <xacro:property name="joint_camera_y" value="0" />
  8. <xacro:property name="joint_camera_z" value="${base_length / 2 + camera_height / 2}" />
  9. <link name="camera">
  10. <visual>
  11. <geometry>
  12. <box size="${camera_length} ${camera_width} ${camera_height}" />
  13. </geometry>
  14. <origin xyz="0 0 0" rpy="0 0 0" />
  15. <material name="black">
  16. <color rgba="0 0 0 0.8" />
  17. </material>
  18. </visual>
  19. </link>
  20. <joint name="camera2base" type="fixed">
  21. <parent link="base_link" />
  22. <child link="camera" />
  23. <origin xyz="${joint_camera_x} ${joint_camera_y} ${joint_camera_z}" rpy="0 0 0" />
  24. </joint>
  25. </robot>

   保存退出,打开终端输入:

code robot_laser.urdf.xacro

 将下列代码粘贴进去:

  1. <!-- File Name : robot_laser.urdf.xacro -->
  2. <robot name="robot_test" xmlns:xacro="http://wiki.ros.org/xacro">
  3. <xacro:property name="support_radius" value="0.01" />
  4. <xacro:property name="support_length" value="0.15" />
  5. <xacro:property name="laser_radius" value="0.03" />
  6. <xacro:property name="laser_length" value="0.05" />
  7. <xacro:property name="joint_support_x" value="0" />
  8. <xacro:property name="joint_support_y" value="0" />
  9. <xacro:property name="joint_support_z" value="${base_length / 2 + support_length / 2}" />
  10. <xacro:property name="joint_laser_x" value="0" />
  11. <xacro:property name="joint_laser_y" value="0" />
  12. <xacro:property name="joint_laser_z" value="${support_length / 2 + laser_length / 2}" />
  13. <link name="support">
  14. <visual>
  15. <geometry>
  16. <cylinder radius="${support_radius}" length="${support_length}" />
  17. </geometry>
  18. <material name="yellow">
  19. <color rgba="0.8 0.5 0.0 0.5" />
  20. </material>
  21. </visual>
  22. </link>
  23. <joint name="support2base" type="fixed">
  24. <parent link="base_link" />
  25. <child link="support"/>
  26. <origin xyz="${joint_support_x} ${joint_support_y} ${joint_support_z}" rpy="0 0 0" />
  27. </joint>
  28. <link name="laser">
  29. <visual>
  30. <geometry>
  31. <cylinder radius="${laser_radius}" length="${laser_length}" />
  32. </geometry>
  33. <material name="black">
  34. <color rgba="0 0 0 0.5" />
  35. </material>
  36. </visual>
  37. </link>
  38. <joint name="laser2support" type="fixed">
  39. <parent link="support" />
  40. <child link="laser"/>
  41. <origin xyz="${joint_laser_x} ${joint_laser_y} ${joint_laser_z}" rpy="0 0 0" />
  42. </joint>
  43. </robot>

保存退出,打开终端:

cd .. && mkdir launch
touch robot_test.launch && code robot_test.launch

将下列代码粘贴进去:

  1. <!-- File Name : robot_test.launch -->
  2. <launch>
  3. <param name="robot_description" command="$(find xacro)/xacro $(find robot_description_test)/urdf/robot.urdf.xacro" />
  4. <node pkg="joint_state_publisher" name="joint_state_publisher" type="joint_state_publisher" />
  5. <node pkg="robot_state_publisher" name="robot_state_publisher" type="robot_state_publisher" />
  6. </launch>

 保存退出,打开终端:

cd ../../../ && echo 'source /home/m0rtzz/Workspaces/navigation_entity_test_ws/devel/setup.bash' >> ~/.bashrc && source ~/.bashrc

 测试一下:

roslaunch robot_description_test robot_test.launch

756d60eb62c14cfe82eafa7e3bdf4862.png

之后Ctrl+Alt+T打开一个新的终端,输入:

rviz

4dc525d781d94b19bfe14f73cd68738f.png

将 Fixed Frame设置为base_footprint:c37069f5d4ba47cf94e637d64a15f416.png

 Add一个RobotModel:4111cf3ff31e4bda9b90de04c5d76e8a.png

 Add一个TF:

9b1fddd56a704702b30240024f4e7b65.png

cd src/entity_test/ && mkdir launch && cd launch/ 
touch gmapping.launch && code gmapping.launch

将下列代码粘贴进去:

  1. <!-- File Name : gmapping.launch -->
  2. <launch>
  3. <node pkg="gmapping" type="slam_gmapping" name="slam_gmapping" output="screen">
  4. <remap from="scan" to="scan"/>
  5. <param name="base_frame" value="base_footprint"/><!--底盘坐标系-->
  6. <param name="odom_frame" value="odom"/> <!--里程计坐标系-->
  7. <param name="map_update_interval" value="5.0"/>
  8. <param name="maxUrange" value="16.0"/>
  9. <param name="sigma" value="0.05"/>
  10. <param name="kernelSize" value="1"/>
  11. <param name="lstep" value="0.05"/>
  12. <param name="astep" value="0.05"/>
  13. <param name="iterations" value="5"/>
  14. <param name="lsigma" value="0.075"/>
  15. <param name="ogain" value="3.0"/>
  16. <param name="lskip" value="0"/>
  17. <param name="srr" value="0.1"/>
  18. <param name="srt" value="0.2"/>
  19. <param name="str" value="0.1"/>
  20. <param name="stt" value="0.2"/>
  21. <param name="linearUpdate" value="1.0"/>
  22. <param name="angularUpdate" value="0.5"/>
  23. <param name="temporalUpdate" value="3.0"/>
  24. <param name="resampleThreshold" value="0.5"/>
  25. <param name="particles" value="30"/>
  26. <param name="xmin" value="-50.0"/>
  27. <param name="ymin" value="-50.0"/>
  28. <param name="xmax" value="50.0"/>
  29. <param name="ymax" value="50.0"/>
  30. <param name="delta" value="0.05"/>
  31. <param name="llsamplerange" value="0.01"/>
  32. <param name="llsamplestep" value="0.01"/>
  33. <param name="lasamplerange" value="0.005"/>
  34. <param name="lasamplestep" value="0.005"/>
  35. </node>
  36. </launch>
cd .. && mkdir map
cd launch && touch map_save.launch && code map_save.launch

将下列代码粘贴进去:

  1. <!-- File Name : map_save.launch -->
  2. <launch>
  3. <arg name="filename" value="$(find entity_test)/map/nav" />
  4. <node name="map_save" pkg="map_server" type="map_saver" args="-f $(arg filename)" />
  5. </launch>
 touch map_server.launch && code map_server.launch

 将下列代码粘贴进去:

  1. <!-- File Name : map_server.launch -->
  2. <launch>
  3. <!-- 设置地图的配置文件 -->
  4. <arg name="map" default="nav.yaml" />
  5. <!-- 运行地图服务器,并且加载设置的地图-->
  6. <node name="map_server" pkg="map_server" type="map_server" args="$(find entity_test)/map/$(arg map)"/>
  7. </launch>
touch amcl.launch && code amcl.launch

 将下列代码粘贴进去:

  1. <!-- File Name : amcl.launch -->
  2. <launch>
  3. <node pkg="amcl" type="amcl" name="amcl" output="screen">
  4. <!-- Publish scans from best pose at a max of 10 Hz -->
  5. <param name="odom_model_type" value="diff"/><!-- 里程计模式为差分 -->
  6. <param name="odom_alpha5" value="0.1"/>
  7. <param name="transform_tolerance" value="0.2" />
  8. <param name="gui_publish_rate" value="10.0"/>
  9. <param name="laser_max_beams" value="30"/>
  10. <param name="min_particles" value="500"/>
  11. <param name="max_particles" value="5000"/>
  12. <param name="kld_err" value="0.05"/>
  13. <param name="kld_z" value="0.99"/>
  14. <param name="odom_alpha1" value="0.2"/>
  15. <param name="odom_alpha2" value="0.2"/>
  16. <!-- translation std dev, m -->
  17. <param name="odom_alpha3" value="0.8"/>
  18. <param name="odom_alpha4" value="0.2"/>
  19. <param name="laser_z_hit" value="0.5"/>
  20. <param name="laser_z_short" value="0.05"/>
  21. <param name="laser_z_max" value="0.05"/>
  22. <param name="laser_z_rand" value="0.5"/>
  23. <param name="laser_sigma_hit" value="0.2"/>
  24. <param name="laser_lambda_short" value="0.1"/>
  25. <param name="laser_lambda_short" value="0.1"/>
  26. <param name="laser_model_type" value="likelihood_field"/>
  27. <!-- <param name="laser_model_type" value="beam"/> -->
  28. <param name="laser_likelihood_max_dist" value="2.0"/>
  29. <param name="update_min_d" value="0.2"/>
  30. <param name="update_min_a" value="0.5"/>
  31. <param name="odom_frame_id" value="odom"/><!-- 里程计坐标系 -->
  32. <param name="base_frame_id" value="base_footprint"/><!-- 添加机器人基坐标系 -->
  33. <param name="global_frame_id" value="map"/><!-- 添加地图坐标系 -->
  34. </node>
  35. </launch>
cd .. && mkdir param && cd param/ && touch {costmap_common_params.yaml,local_costmap_params.yaml,global_costmap_params.yaml,base_local_planner_params.yaml} && code .

 将下列几个代码分别粘贴进去:

  1. # File Name : base_local_planner_params.yaml
  2. TrajectoryPlannerROS:
  3. # Robot Configuration Parameters
  4. max_vel_x: 0.5 # X 方向最大速度
  5. min_vel_x: 0.1 # X 方向最小速速
  6. max_vel_theta: 1.0 #
  7. min_vel_theta: -1.0
  8. min_in_place_vel_theta: 1.0
  9. acc_lim_x: 1.0 # X 加速限制
  10. acc_lim_y: 0.0 # Y 加速限制
  11. acc_lim_theta: 0.6 # 角速度加速限制
  12. # Goal Tolerance Parameters,目标公差
  13. xy_goal_tolerance: 0.10
  14. yaw_goal_tolerance: 0.05
  15. # Differential-drive robot configuration
  16. # 是否是全向移动机器人
  17. holonomic_robot: false
  18. # Forward Simulation Parameters,前进模拟参数
  19. sim_time: 0.8
  20. vx_samples: 18
  21. vtheta_samples: 20
  22. sim_granularity: 0.05
  1. # File Name : cost_common_params.yaml
  2. #机器人几何参,如果机器人是圆形,设置 robot_radius,如果是其他形状设置 footprint
  3. robot_radius: 0.12 #圆形
  4. # footprint: [[-0.12, -0.12], [-0.12, 0.12], [0.12, 0.12], [0.12, -0.12]] #其他形状
  5. obstacle_range: 3.0 # 用于障碍物探测,比如: 值为 3.0,意味着检测到距离小于 3 米的障碍物时,就会引入代价地图
  6. raytrace_range: 3.5 # 用于清除障碍物,比如:值为 3.5,意味着清除代价地图中 3.5 米以外的障碍物
  7. #膨胀半径,扩展在碰撞区域以外的代价区域,使得机器人规划路径避开障碍物
  8. inflation_radius: 0.2
  9. #代价比例系数,越大则代价值越小
  10. cost_scaling_factor: 3.0
  11. #地图类型
  12. map_type: costmap
  13. #导航包所需要的传感器
  14. observation_sources: scan
  15. #对传感器的坐标系和数据进行配置。这个也会用于代价地图添加和清除障碍物。例如,你可以用激光雷达传感器用于在代价地图添加障碍物,再添加kinect用于导航和清除障碍物。
  16. scan: {sensor_frame: laser, data_type: LaserScan, topic: scan, marking: true, clearing: true}
  1. # File Name : global_costmap_params.yaml
  2. global_costmap:
  3. global_frame: map #地图坐标系
  4. robot_base_frame: base_footprint #机器人坐标系
  5. # 以此实现坐标变换
  6. update_frequency: 1.0 #代价地图更新频率
  7. publish_frequency: 1.0 #代价地图的发布频率
  8. transform_tolerance: 0.5 #等待坐标变换发布信息的超时时间
  9. static_map: true # 是否使用一个地图或者地图服务器来初始化全局代价地图,如果不使用静态地图,这个参数为false.
  1. # File Name : local_costmap_params.yaml
  2. local_costmap:
  3. global_frame: odom #里程计坐标系
  4. robot_base_frame: base_footprint #机器人坐标系
  5. update_frequency: 10.0 #代价地图更新频率
  6. publish_frequency: 10.0 #代价地图的发布频率
  7. transform_tolerance: 0.5 #等待坐标变换发布信息的超时时间
  8. static_map: false #不需要静态地图,可以提升导航效果
  9. rolling_window: true #是否使用动态窗口,默认为false,在静态的全局地图中,地图不会变化
  10. width: 3 # 局部地图宽度 单位是 m
  11. height: 3 # 局部地图高度 单位是 m
  12. resolution: 0.05 # 局部地图分辨率 单位是 m,一般与静态地图分辨率保持一致
cd ../launch && touch move_base.launch && code move_base.launch

将下列代码粘贴进去: 

  1. <!-- File Name : move_base.launch -->
  2. <launch>
  3. <node pkg="move_base" type="move_base" respawn="false" name="move_base" output="screen" clear_params="true">
  4. <rosparam file="$(find nav)/param/costmap_common_params.yaml" command="load" ns="global_costmap" />
  5. <rosparam file="$(find nav)/param/costmap_common_params.yaml" command="load" ns="local_costmap" />
  6. <rosparam file="$(find nav)/param/local_costmap_params.yaml" command="load" />
  7. <rosparam file="$(find nav)/param/global_costmap_params.yaml" command="load" />
  8. <rosparam file="$(find nav)/param/base_local_planner_params.yaml" command="load" />
  9. </node>
  10. </launch>
touch auto_slam.launch && code auto_slam.launch

将下列代码粘贴进去:

  1. <!-- File Name : auto_slam.launch -->
  2. <launch>
  3. <!-- 启动SLAM节点 -->
  4. <include file="$(find entity_test)/launch/gmapping.launch" />
  5. <!-- 运行move_base节点 -->
  6. <include file="$(find entity_test)/launch/move_base.launch" />
  7. </launch>

23.安装配置caffe

Reference:

https://blog.csdn.net/weixin_39161727/article/details/120136500icon-default.png?t=N7T8https://blog.csdn.net/weixin_39161727/article/details/120136500首先安装依赖:

  1. sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
  2. sudo apt-get install --no-install-recommends libboost-all-dev
  3. sudo apt-get install libatlas-base-dev
  4. sudo apt-get install python-dev
  5. sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
 git clone https://gitee.com/quietbirds/caffe.git caffe
cd caffe/ && sudo cp Makefile.config.example Makefile.config
sudo gedit Makefile.config
  1. ## Refer to http://caffe.berkeleyvision.org/installation.html
  2. # Contributions simplifying and improving our build system are welcome!
  3. # cuDNN acceleration switch (uncomment to build with cuDNN).
  4. USE_CUDNN := 1
  5. # CPU-only switch (uncomment to build without GPU support).
  6. # CPU_ONLY := 1
  7. # uncomment to disable IO dependencies and corresponding data layers
  8. # USE_OPENCV := 0
  9. # USE_LEVELDB := 0
  10. # USE_LMDB := 0
  11. # This code is taken from https://github.com/sh1r0/caffe-android-lib
  12. # USE_HDF5 := 0
  13. # uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)
  14. # You should not set this flag if you will be reading LMDBs with any
  15. # possibility of simultaneous read and write
  16. # ALLOW_LMDB_NOLOCK := 1
  17. # Uncomment if you're using OpenCV 3
  18. OPENCV_VERSION := 3
  19. # To customize your choice of compiler, uncomment and set the following.
  20. # N.B. the default for Linux is g++ and the default for OSX is clang++
  21. CUSTOM_CXX := g++
  22. # CUDA directory contains bin/ and lib/ directories that we need.
  23. CUDA_DIR := /usr/local/cuda
  24. # On Ubuntu 14.04, if cuda tools are installed via
  25. # "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
  26. # CUDA_DIR := /usr
  27. # CUDA architecture setting: going with all of them.
  28. # For CUDA < 6.0, comment the *_50 through *_61 lines for compatibility.
  29. # For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility.
  30. # For CUDA >= 9.0, comment the *_20 and *_21 lines for compatibility.
  31. CUDA_ARCH := #-gencode arch=compute_20,code=sm_20 \
  32. #-gencode arch=compute_20,code=sm_21 \
  33. #-gencode arch=compute_30,code=sm_30 \
  34. -gencode arch=compute_35,code=sm_35 \
  35. -gencode arch=compute_50,code=sm_50 \
  36. -gencode arch=compute_52,code=sm_52 \
  37. -gencode arch=compute_60,code=sm_60 \
  38. -gencode arch=compute_61,code=sm_61 \
  39. -gencode arch=compute_61,code=compute_61
  40. # BLAS choice:
  41. # atlas for ATLAS (default)
  42. # mkl for MKL
  43. # open for OpenBlas
  44. BLAS := open
  45. # Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
  46. # Leave commented to accept the defaults for your choice of BLAS
  47. # (which should work)!
  48. # BLAS_INCLUDE := /path/to/your/blas
  49. # BLAS_LIB := /path/to/your/blas
  50. # Homebrew puts openblas in a directory that is not on the standard search path
  51. # BLAS_INCLUDE := $(shell brew --prefix openblas)/include
  52. # BLAS_LIB := $(shell brew --prefix openblas)/lib
  53. # This is required only if you will compile the matlab interface.
  54. # MATLAB directory should contain the mex binary in /bin.
  55. # MATLAB_DIR := /usr/local
  56. # MATLAB_DIR := /Applications/MATLAB_R2012b.app
  57. # NOTE: this is required only if you will compile the python interface.
  58. # We need to be able to find Python.h and numpy/arrayobject.h.
  59. PYTHON_INCLUDE := /usr/include/python2.7 \
  60. /usr/lib/python2.7/dist-packages/numpy/core/include
  61. # Anaconda Python distribution is quite popular. Include path:
  62. # Verify anaconda location, sometimes it's in root.
  63. # ANACONDA_HOME := $(HOME)/anaconda
  64. # PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
  65. # $(ANACONDA_HOME)/include/python2.7 \
  66. # $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include
  67. # Uncomment to use Python 3 (default is Python 2)
  68. PYTHON_LIBRARIES := boost_python3 python3.6m
  69. PYTHON_INCLUDE := /usr/include/python3.6m \
  70. /usr/lib/python3.6/dist-packages/numpy/core/include
  71. # We need to be able to find libpythonX.X.so or .dylib.
  72. PYTHON_LIB := /usr/lib
  73. # PYTHON_LIB := $(ANACONDA_HOME)/lib
  74. # Homebrew installs numpy in a non standard path (keg only)
  75. # PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include
  76. # PYTHON_LIB += $(shell brew --prefix numpy)/lib
  77. # Uncomment to support layers written in Python (will link against Python libs)
  78. WITH_PYTHON_LAYER := 1
  79. # Whatever else you find you need goes here.
  80. INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
  81. LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/
  82. # If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
  83. # INCLUDE_DIRS += $(shell brew --prefix)/include
  84. # LIBRARY_DIRS += $(shell brew --prefix)/lib
  85. # NCCL acceleration switch (uncomment to build with NCCL)
  86. # https://github.com/NVIDIA/nccl (last tested version: v1.2.3-1+cuda8.0)
  87. # USE_NCCL := 1
  88. # Uncomment to use `pkg-config` to specify OpenCV library paths.
  89. # (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
  90. # USE_PKG_CONFIG := 1
  91. # N.B. both build and distribute dirs are cleared on `make clean`
  92. BUILD_DIR := build
  93. DISTRIBUTE_DIR := distribute
  94. # Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
  95. # DEBUG := 1
  96. # The ID of the GPU that 'make runtest' will use to run unit tests.
  97. TEST_GPUID := 0
  98. # enable pretty build (comment to see full commands)
  99. Q ?= @
sudo gedit Makefile
  1. PROJECT := caffe
  2. CONFIG_FILE := Makefile.config
  3. # Explicitly check for the config file, otherwise make -k will proceed anyway.
  4. ifeq ($(wildcard $(CONFIG_FILE)),)
  5. $(error $(CONFIG_FILE) not found. See $(CONFIG_FILE).example.)
  6. endif
  7. include $(CONFIG_FILE)
  8. BUILD_DIR_LINK := $(BUILD_DIR)
  9. ifeq ($(RELEASE_BUILD_DIR),)
  10. RELEASE_BUILD_DIR := .$(BUILD_DIR)_release
  11. endif
  12. ifeq ($(DEBUG_BUILD_DIR),)
  13. DEBUG_BUILD_DIR := .$(BUILD_DIR)_debug
  14. endif
  15. DEBUG ?= 0
  16. ifeq ($(DEBUG), 1)
  17. BUILD_DIR := $(DEBUG_BUILD_DIR)
  18. OTHER_BUILD_DIR := $(RELEASE_BUILD_DIR)
  19. else
  20. BUILD_DIR := $(RELEASE_BUILD_DIR)
  21. OTHER_BUILD_DIR := $(DEBUG_BUILD_DIR)
  22. endif
  23. # All of the directories containing code.
  24. SRC_DIRS := $(shell find * -type d -exec bash -c "find {} -maxdepth 1 \
  25. \( -name '*.cpp' -o -name '*.proto' \) | grep -q ." \; -print)
  26. # The target shared library name
  27. LIBRARY_NAME := $(PROJECT)
  28. LIB_BUILD_DIR := $(BUILD_DIR)/lib
  29. STATIC_NAME := $(LIB_BUILD_DIR)/lib$(LIBRARY_NAME).a
  30. DYNAMIC_VERSION_MAJOR := 1
  31. DYNAMIC_VERSION_MINOR := 0
  32. DYNAMIC_VERSION_REVISION := 0
  33. DYNAMIC_NAME_SHORT := lib$(LIBRARY_NAME).so
  34. #DYNAMIC_SONAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR)
  35. DYNAMIC_VERSIONED_NAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION)
  36. DYNAMIC_NAME := $(LIB_BUILD_DIR)/$(DYNAMIC_VERSIONED_NAME_SHORT)
  37. COMMON_FLAGS += -DCAFFE_VERSION=$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION)
  38. ##############################
  39. # Get all source files
  40. ##############################
  41. # CXX_SRCS are the source files excluding the test ones.
  42. CXX_SRCS := $(shell find src/$(PROJECT) ! -name "test_*.cpp" -name "*.cpp")
  43. # CU_SRCS are the cuda source files
  44. CU_SRCS := $(shell find src/$(PROJECT) ! -name "test_*.cu" -name "*.cu")
  45. # TEST_SRCS are the test source files
  46. TEST_MAIN_SRC := src/$(PROJECT)/test/test_caffe_main.cpp
  47. TEST_SRCS := $(shell find src/$(PROJECT) -name "test_*.cpp")
  48. TEST_SRCS := $(filter-out $(TEST_MAIN_SRC), $(TEST_SRCS))
  49. TEST_CU_SRCS := $(shell find src/$(PROJECT) -name "test_*.cu")
  50. GTEST_SRC := src/gtest/gtest-all.cpp
  51. # TOOL_SRCS are the source files for the tool binaries
  52. TOOL_SRCS := $(shell find tools -name "*.cpp")
  53. # EXAMPLE_SRCS are the source files for the example binaries
  54. EXAMPLE_SRCS := $(shell find examples -name "*.cpp")
  55. # BUILD_INCLUDE_DIR contains any generated header files we want to include.
  56. BUILD_INCLUDE_DIR := $(BUILD_DIR)/src
  57. # PROTO_SRCS are the protocol buffer definitions
  58. PROTO_SRC_DIR := src/$(PROJECT)/proto
  59. PROTO_SRCS := $(wildcard $(PROTO_SRC_DIR)/*.proto)
  60. # PROTO_BUILD_DIR will contain the .cc and obj files generated from
  61. # PROTO_SRCS; PROTO_BUILD_INCLUDE_DIR will contain the .h header files
  62. PROTO_BUILD_DIR := $(BUILD_DIR)/$(PROTO_SRC_DIR)
  63. PROTO_BUILD_INCLUDE_DIR := $(BUILD_INCLUDE_DIR)/$(PROJECT)/proto
  64. # NONGEN_CXX_SRCS includes all source/header files except those generated
  65. # automatically (e.g., by proto).
  66. NONGEN_CXX_SRCS := $(shell find \
  67. src/$(PROJECT) \
  68. include/$(PROJECT) \
  69. python/$(PROJECT) \
  70. matlab/+$(PROJECT)/private \
  71. examples \
  72. tools \
  73. -name "*.cpp" -or -name "*.hpp" -or -name "*.cu" -or -name "*.cuh")
  74. LINT_SCRIPT := scripts/cpp_lint.py
  75. LINT_OUTPUT_DIR := $(BUILD_DIR)/.lint
  76. LINT_EXT := lint.txt
  77. LINT_OUTPUTS := $(addsuffix .$(LINT_EXT), $(addprefix $(LINT_OUTPUT_DIR)/, $(NONGEN_CXX_SRCS)))
  78. EMPTY_LINT_REPORT := $(BUILD_DIR)/.$(LINT_EXT)
  79. NONEMPTY_LINT_REPORT := $(BUILD_DIR)/$(LINT_EXT)
  80. # PY$(PROJECT)_SRC is the python wrapper for $(PROJECT)
  81. PY$(PROJECT)_SRC := python/$(PROJECT)/_$(PROJECT).cpp
  82. PY$(PROJECT)_SO := python/$(PROJECT)/_$(PROJECT).so
  83. PY$(PROJECT)_HXX := include/$(PROJECT)/layers/python_layer.hpp
  84. # MAT$(PROJECT)_SRC is the mex entrance point of matlab package for $(PROJECT)
  85. MAT$(PROJECT)_SRC := matlab/+$(PROJECT)/private/$(PROJECT)_.cpp
  86. ifneq ($(MATLAB_DIR),)
  87. MAT_SO_EXT := $(shell $(MATLAB_DIR)/bin/mexext)
  88. endif
  89. MAT$(PROJECT)_SO := matlab/+$(PROJECT)/private/$(PROJECT)_.$(MAT_SO_EXT)
  90. ##############################
  91. # Derive generated files
  92. ##############################
  93. # The generated files for protocol buffers
  94. PROTO_GEN_HEADER_SRCS := $(addprefix $(PROTO_BUILD_DIR)/, \
  95. $(notdir ${PROTO_SRCS:.proto=.pb.h}))
  96. PROTO_GEN_HEADER := $(addprefix $(PROTO_BUILD_INCLUDE_DIR)/, \
  97. $(notdir ${PROTO_SRCS:.proto=.pb.h}))
  98. PROTO_GEN_CC := $(addprefix $(BUILD_DIR)/, ${PROTO_SRCS:.proto=.pb.cc})
  99. PY_PROTO_BUILD_DIR := python/$(PROJECT)/proto
  100. PY_PROTO_INIT := python/$(PROJECT)/proto/__init__.py
  101. PROTO_GEN_PY := $(foreach file,${PROTO_SRCS:.proto=_pb2.py}, \
  102. $(PY_PROTO_BUILD_DIR)/$(notdir $(file)))
  103. # The objects corresponding to the source files
  104. # These objects will be linked into the final shared library, so we
  105. # exclude the tool, example, and test objects.
  106. CXX_OBJS := $(addprefix $(BUILD_DIR)/, ${CXX_SRCS:.cpp=.o})
  107. CU_OBJS := $(addprefix $(BUILD_DIR)/cuda/, ${CU_SRCS:.cu=.o})
  108. PROTO_OBJS := ${PROTO_GEN_CC:.cc=.o}
  109. OBJS := $(PROTO_OBJS) $(CXX_OBJS) $(CU_OBJS)
  110. # tool, example, and test objects
  111. TOOL_OBJS := $(addprefix $(BUILD_DIR)/, ${TOOL_SRCS:.cpp=.o})
  112. TOOL_BUILD_DIR := $(BUILD_DIR)/tools
  113. TEST_CXX_BUILD_DIR := $(BUILD_DIR)/src/$(PROJECT)/test
  114. TEST_CU_BUILD_DIR := $(BUILD_DIR)/cuda/src/$(PROJECT)/test
  115. TEST_CXX_OBJS := $(addprefix $(BUILD_DIR)/, ${TEST_SRCS:.cpp=.o})
  116. TEST_CU_OBJS := $(addprefix $(BUILD_DIR)/cuda/, ${TEST_CU_SRCS:.cu=.o})
  117. TEST_OBJS := $(TEST_CXX_OBJS) $(TEST_CU_OBJS)
  118. GTEST_OBJ := $(addprefix $(BUILD_DIR)/, ${GTEST_SRC:.cpp=.o})
  119. EXAMPLE_OBJS := $(addprefix $(BUILD_DIR)/, ${EXAMPLE_SRCS:.cpp=.o})
  120. # Output files for automatic dependency generation
  121. DEPS := ${CXX_OBJS:.o=.d} ${CU_OBJS:.o=.d} ${TEST_CXX_OBJS:.o=.d} \
  122. ${TEST_CU_OBJS:.o=.d} $(BUILD_DIR)/${MAT$(PROJECT)_SO:.$(MAT_SO_EXT)=.d}
  123. # tool, example, and test bins
  124. TOOL_BINS := ${TOOL_OBJS:.o=.bin}
  125. EXAMPLE_BINS := ${EXAMPLE_OBJS:.o=.bin}
  126. # symlinks to tool bins without the ".bin" extension
  127. TOOL_BIN_LINKS := ${TOOL_BINS:.bin=}
  128. # Put the test binaries in build/test for convenience.
  129. TEST_BIN_DIR := $(BUILD_DIR)/test
  130. TEST_CU_BINS := $(addsuffix .testbin,$(addprefix $(TEST_BIN_DIR)/, \
  131. $(foreach obj,$(TEST_CU_OBJS),$(basename $(notdir $(obj))))))
  132. TEST_CXX_BINS := $(addsuffix .testbin,$(addprefix $(TEST_BIN_DIR)/, \
  133. $(foreach obj,$(TEST_CXX_OBJS),$(basename $(notdir $(obj))))))
  134. TEST_BINS := $(TEST_CXX_BINS) $(TEST_CU_BINS)
  135. # TEST_ALL_BIN is the test binary that links caffe dynamically.
  136. TEST_ALL_BIN := $(TEST_BIN_DIR)/test_all.testbin
  137. ##############################
  138. # Derive compiler warning dump locations
  139. ##############################
  140. WARNS_EXT := warnings.txt
  141. CXX_WARNS := $(addprefix $(BUILD_DIR)/, ${CXX_SRCS:.cpp=.o.$(WARNS_EXT)})
  142. CU_WARNS := $(addprefix $(BUILD_DIR)/cuda/, ${CU_SRCS:.cu=.o.$(WARNS_EXT)})
  143. TOOL_WARNS := $(addprefix $(BUILD_DIR)/, ${TOOL_SRCS:.cpp=.o.$(WARNS_EXT)})
  144. EXAMPLE_WARNS := $(addprefix $(BUILD_DIR)/, ${EXAMPLE_SRCS:.cpp=.o.$(WARNS_EXT)})
  145. TEST_WARNS := $(addprefix $(BUILD_DIR)/, ${TEST_SRCS:.cpp=.o.$(WARNS_EXT)})
  146. TEST_CU_WARNS := $(addprefix $(BUILD_DIR)/cuda/, ${TEST_CU_SRCS:.cu=.o.$(WARNS_EXT)})
  147. ALL_CXX_WARNS := $(CXX_WARNS) $(TOOL_WARNS) $(EXAMPLE_WARNS) $(TEST_WARNS)
  148. ALL_CU_WARNS := $(CU_WARNS) $(TEST_CU_WARNS)
  149. ALL_WARNS := $(ALL_CXX_WARNS) $(ALL_CU_WARNS)
  150. EMPTY_WARN_REPORT := $(BUILD_DIR)/.$(WARNS_EXT)
  151. NONEMPTY_WARN_REPORT := $(BUILD_DIR)/$(WARNS_EXT)
  152. ##############################
  153. # Derive include and lib directories
  154. ##############################
  155. CUDA_INCLUDE_DIR := $(CUDA_DIR)/include
  156. CUDA_LIB_DIR :=
  157. # add <cuda>/lib64 only if it exists
  158. ifneq ("$(wildcard $(CUDA_DIR)/lib64)","")
  159. CUDA_LIB_DIR += $(CUDA_DIR)/lib64
  160. endif
  161. CUDA_LIB_DIR += $(CUDA_DIR)/lib
  162. INCLUDE_DIRS += $(BUILD_INCLUDE_DIR) ./src ./include
  163. ifneq ($(CPU_ONLY), 1)
  164. INCLUDE_DIRS += $(CUDA_INCLUDE_DIR)
  165. LIBRARY_DIRS += $(CUDA_LIB_DIR)
  166. LIBRARIES := cudart cublas curand
  167. endif
  168. LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial
  169. # handle IO dependencies
  170. USE_LEVELDB ?= 1
  171. USE_LMDB ?= 1
  172. # This code is taken from https://github.com/sh1r0/caffe-android-lib
  173. USE_HDF5 ?= 1
  174. USE_OPENCV ?= 1
  175. ifeq ($(USE_LEVELDB), 1)
  176. LIBRARIES += leveldb snappy
  177. endif
  178. ifeq ($(USE_LMDB), 1)
  179. LIBRARIES += lmdb
  180. endif
  181. # This code is taken from https://github.com/sh1r0/caffe-android-lib
  182. ifeq ($(USE_HDF5), 1)
  183. LIBRARIES += hdf5_hl hdf5
  184. endif
  185. ifeq ($(USE_OPENCV), 1)
  186. LIBRARIES += opencv_core opencv_highgui opencv_imgproc
  187. ifeq ($(OPENCV_VERSION), 3)
  188. LIBRARIES += opencv_imgcodecs
  189. endif
  190. endif
  191. PYTHON_LIBRARIES ?= boost_python python2.7
  192. WARNINGS := -Wall -Wno-sign-compare
  193. ##############################
  194. # Set build directories
  195. ##############################
  196. DISTRIBUTE_DIR ?= distribute
  197. DISTRIBUTE_SUBDIRS := $(DISTRIBUTE_DIR)/bin $(DISTRIBUTE_DIR)/lib
  198. DIST_ALIASES := dist
  199. ifneq ($(strip $(DISTRIBUTE_DIR)),distribute)
  200. DIST_ALIASES += distribute
  201. endif
  202. ALL_BUILD_DIRS := $(sort $(BUILD_DIR) $(addprefix $(BUILD_DIR)/, $(SRC_DIRS)) \
  203. $(addprefix $(BUILD_DIR)/cuda/, $(SRC_DIRS)) \
  204. $(LIB_BUILD_DIR) $(TEST_BIN_DIR) $(PY_PROTO_BUILD_DIR) $(LINT_OUTPUT_DIR) \
  205. $(DISTRIBUTE_SUBDIRS) $(PROTO_BUILD_INCLUDE_DIR))
  206. ##############################
  207. # Set directory for Doxygen-generated documentation
  208. ##############################
  209. DOXYGEN_CONFIG_FILE ?= ./.Doxyfile
  210. # should be the same as OUTPUT_DIRECTORY in the .Doxyfile
  211. DOXYGEN_OUTPUT_DIR ?= ./doxygen
  212. DOXYGEN_COMMAND ?= doxygen
  213. # All the files that might have Doxygen documentation.
  214. DOXYGEN_SOURCES := $(shell find \
  215. src/$(PROJECT) \
  216. include/$(PROJECT) \
  217. python/ \
  218. matlab/ \
  219. examples \
  220. tools \
  221. -name "*.cpp" -or -name "*.hpp" -or -name "*.cu" -or -name "*.cuh" -or \
  222. -name "*.py" -or -name "*.m")
  223. DOXYGEN_SOURCES += $(DOXYGEN_CONFIG_FILE)
  224. ##############################
  225. # Configure build
  226. ##############################
  227. # Determine platform
  228. UNAME := $(shell uname -s)
  229. ifeq ($(UNAME), Linux)
  230. LINUX := 1
  231. else ifeq ($(UNAME), Darwin)
  232. OSX := 1
  233. OSX_MAJOR_VERSION := $(shell sw_vers -productVersion | cut -f 1 -d .)
  234. OSX_MINOR_VERSION := $(shell sw_vers -productVersion | cut -f 2 -d .)
  235. endif
  236. # Linux
  237. ifeq ($(LINUX), 1)
  238. CXX ?= /usr/bin/g++
  239. GCCVERSION := $(shell $(CXX) -dumpversion | cut -f1,2 -d.)
  240. # older versions of gcc are too dumb to build boost with -Wuninitalized
  241. ifeq ($(shell echo | awk '{exit $(GCCVERSION) < 4.6;}'), 1)
  242. WARNINGS += -Wno-uninitialized
  243. endif
  244. # boost::thread is reasonably called boost_thread (compare OS X)
  245. # We will also explicitly add stdc++ to the link target.
  246. LIBRARIES += boost_thread stdc++
  247. VERSIONFLAGS += -Wl,-soname,$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../lib
  248. endif
  249. # OS X:
  250. # clang++ instead of g++
  251. # libstdc++ for NVCC compatibility on OS X >= 10.9 with CUDA < 7.0
  252. ifeq ($(OSX), 1)
  253. CXX := /usr/bin/clang++
  254. ifneq ($(CPU_ONLY), 1)
  255. CUDA_VERSION := $(shell $(CUDA_DIR)/bin/nvcc -V | grep -o 'release [0-9.]*' | tr -d '[a-z ]')
  256. ifeq ($(shell echo | awk '{exit $(CUDA_VERSION) < 7.0;}'), 1)
  257. CXXFLAGS += -stdlib=libstdc++
  258. LINKFLAGS += -stdlib=libstdc++
  259. endif
  260. # clang throws this warning for cuda headers
  261. WARNINGS += -Wno-unneeded-internal-declaration
  262. # 10.11 strips DYLD_* env vars so link CUDA (rpath is available on 10.5+)
  263. OSX_10_OR_LATER := $(shell [ $(OSX_MAJOR_VERSION) -ge 10 ] && echo true)
  264. OSX_10_5_OR_LATER := $(shell [ $(OSX_MINOR_VERSION) -ge 5 ] && echo true)
  265. ifeq ($(OSX_10_OR_LATER),true)
  266. ifeq ($(OSX_10_5_OR_LATER),true)
  267. LDFLAGS += -Wl,-rpath,$(CUDA_LIB_DIR)
  268. endif
  269. endif
  270. endif
  271. # gtest needs to use its own tuple to not conflict with clang
  272. COMMON_FLAGS += -DGTEST_USE_OWN_TR1_TUPLE=1
  273. # boost::thread is called boost_thread-mt to mark multithreading on OS X
  274. LIBRARIES += boost_thread-mt
  275. # we need to explicitly ask for the rpath to be obeyed
  276. ORIGIN := @loader_path
  277. VERSIONFLAGS += -Wl,-install_name,@rpath/$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../../build/lib
  278. else
  279. ORIGIN := \$$ORIGIN
  280. endif
  281. # Custom compiler
  282. ifdef CUSTOM_CXX
  283. CXX := $(CUSTOM_CXX)
  284. endif
  285. # Static linking
  286. ifneq (,$(findstring clang++,$(CXX)))
  287. STATIC_LINK_COMMAND := -Wl,-force_load $(STATIC_NAME)
  288. else ifneq (,$(findstring g++,$(CXX)))
  289. STATIC_LINK_COMMAND := -Wl,--whole-archive $(STATIC_NAME) -Wl,--no-whole-archive
  290. else
  291. # The following line must not be indented with a tab, since we are not inside a target
  292. $(error Cannot static link with the $(CXX) compiler)
  293. endif
  294. # Debugging
  295. ifeq ($(DEBUG), 1)
  296. COMMON_FLAGS += -DDEBUG -g -O0
  297. NVCCFLAGS += -G
  298. else
  299. COMMON_FLAGS += -DNDEBUG -O2
  300. endif
  301. # cuDNN acceleration configuration.
  302. ifeq ($(USE_CUDNN), 1)
  303. LIBRARIES += cudnn
  304. COMMON_FLAGS += -DUSE_CUDNN
  305. endif
  306. # NCCL acceleration configuration
  307. ifeq ($(USE_NCCL), 1)
  308. LIBRARIES += nccl
  309. COMMON_FLAGS += -DUSE_NCCL
  310. endif
  311. # configure IO libraries
  312. ifeq ($(USE_OPENCV), 1)
  313. COMMON_FLAGS += -DUSE_OPENCV
  314. endif
  315. ifeq ($(USE_LEVELDB), 1)
  316. COMMON_FLAGS += -DUSE_LEVELDB
  317. endif
  318. ifeq ($(USE_LMDB), 1)
  319. COMMON_FLAGS += -DUSE_LMDB
  320. ifeq ($(ALLOW_LMDB_NOLOCK), 1)
  321. COMMON_FLAGS += -DALLOW_LMDB_NOLOCK
  322. endif
  323. endif
  324. # This code is taken from https://github.com/sh1r0/caffe-android-lib
  325. ifeq ($(USE_HDF5), 1)
  326. COMMON_FLAGS += -DUSE_HDF5
  327. endif
  328. # CPU-only configuration
  329. ifeq ($(CPU_ONLY), 1)
  330. OBJS := $(PROTO_OBJS) $(CXX_OBJS)
  331. TEST_OBJS := $(TEST_CXX_OBJS)
  332. TEST_BINS := $(TEST_CXX_BINS)
  333. ALL_WARNS := $(ALL_CXX_WARNS)
  334. TEST_FILTER := --gtest_filter="-*GPU*"
  335. COMMON_FLAGS += -DCPU_ONLY
  336. endif
  337. # Python layer support
  338. ifeq ($(WITH_PYTHON_LAYER), 1)
  339. COMMON_FLAGS += -DWITH_PYTHON_LAYER
  340. LIBRARIES += $(PYTHON_LIBRARIES)
  341. endif
  342. # BLAS configuration (default = ATLAS)
  343. BLAS ?= atlas
  344. ifeq ($(BLAS), mkl)
  345. # MKL
  346. LIBRARIES += mkl_rt
  347. COMMON_FLAGS += -DUSE_MKL
  348. MKLROOT ?= /opt/intel/mkl
  349. BLAS_INCLUDE ?= $(MKLROOT)/include
  350. BLAS_LIB ?= $(MKLROOT)/lib $(MKLROOT)/lib/intel64
  351. else ifeq ($(BLAS), open)
  352. # OpenBLAS
  353. LIBRARIES += openblas
  354. else
  355. # ATLAS
  356. ifeq ($(LINUX), 1)
  357. ifeq ($(BLAS), atlas)
  358. # Linux simply has cblas and atlas
  359. LIBRARIES += cblas atlas
  360. endif
  361. else ifeq ($(OSX), 1)
  362. # OS X packages atlas as the vecLib framework
  363. LIBRARIES += cblas
  364. # 10.10 has accelerate while 10.9 has veclib
  365. XCODE_CLT_VER := $(shell pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep 'version' | sed 's/[^0-9]*\([0-9]\).*/\1/')
  366. XCODE_CLT_GEQ_7 := $(shell [ $(XCODE_CLT_VER) -gt 6 ] && echo 1)
  367. XCODE_CLT_GEQ_6 := $(shell [ $(XCODE_CLT_VER) -gt 5 ] && echo 1)
  368. ifeq ($(XCODE_CLT_GEQ_7), 1)
  369. 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/Headers
  370. else ifeq ($(XCODE_CLT_GEQ_6), 1)
  371. BLAS_INCLUDE ?= /System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/
  372. LDFLAGS += -framework Accelerate
  373. else
  374. BLAS_INCLUDE ?= /System/Library/Frameworks/vecLib.framework/Versions/Current/Headers/
  375. LDFLAGS += -framework vecLib
  376. endif
  377. endif
  378. endif
  379. INCLUDE_DIRS += $(BLAS_INCLUDE)
  380. LIBRARY_DIRS += $(BLAS_LIB)
  381. LIBRARY_DIRS += $(LIB_BUILD_DIR)
  382. # Automatic dependency generation (nvcc is handled separately)
  383. CXXFLAGS += -MMD -MP
  384. # Complete build flags.
  385. COMMON_FLAGS += $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir))
  386. CXXFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS)
  387. NVCCFLAGS += -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
  388. NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
  389. # mex may invoke an older gcc that is too liberal with -Wuninitalized
  390. MATLAB_CXXFLAGS := $(CXXFLAGS) -Wno-uninitialized
  391. LINKFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS)
  392. USE_PKG_CONFIG ?= 0
  393. ifeq ($(USE_PKG_CONFIG), 1)
  394. PKG_CONFIG := $(shell pkg-config opencv --libs)
  395. else
  396. PKG_CONFIG :=
  397. endif
  398. LDFLAGS += $(foreach librarydir,$(LIBRARY_DIRS),-L$(librarydir)) $(PKG_CONFIG) \
  399. $(foreach library,$(LIBRARIES),-l$(library))
  400. PYTHON_LDFLAGS := $(LDFLAGS) $(foreach library,$(PYTHON_LIBRARIES),-l$(library))
  401. # 'superclean' target recursively* deletes all files ending with an extension
  402. # in $(SUPERCLEAN_EXTS) below. This may be useful if you've built older
  403. # versions of Caffe that do not place all generated files in a location known
  404. # to the 'clean' target.
  405. #
  406. # 'supercleanlist' will list the files to be deleted by make superclean.
  407. #
  408. # * Recursive with the exception that symbolic links are never followed, per the
  409. # default behavior of 'find'.
  410. SUPERCLEAN_EXTS := .so .a .o .bin .testbin .pb.cc .pb.h _pb2.py .cuo
  411. # Set the sub-targets of the 'everything' target.
  412. EVERYTHING_TARGETS := all py$(PROJECT) test warn lint
  413. # Only build matcaffe as part of "everything" if MATLAB_DIR is specified.
  414. ifneq ($(MATLAB_DIR),)
  415. EVERYTHING_TARGETS += mat$(PROJECT)
  416. endif
  417. ##############################
  418. # Define build targets
  419. ##############################
  420. .PHONY: all lib test clean docs linecount lint lintclean tools examples $(DIST_ALIASES) \
  421. py mat py$(PROJECT) mat$(PROJECT) proto runtest \
  422. superclean supercleanlist supercleanfiles warn everything
  423. all: lib tools examples
  424. lib: $(STATIC_NAME) $(DYNAMIC_NAME)
  425. everything: $(EVERYTHING_TARGETS)
  426. linecount:
  427. cloc --read-lang-def=$(PROJECT).cloc \
  428. src/$(PROJECT) include/$(PROJECT) tools examples \
  429. python matlab
  430. lint: $(EMPTY_LINT_REPORT)
  431. lintclean:
  432. @ $(RM) -r $(LINT_OUTPUT_DIR) $(EMPTY_LINT_REPORT) $(NONEMPTY_LINT_REPORT)
  433. docs: $(DOXYGEN_OUTPUT_DIR)
  434. @ cd ./docs ; ln -sfn ../$(DOXYGEN_OUTPUT_DIR)/html doxygen
  435. $(DOXYGEN_OUTPUT_DIR): $(DOXYGEN_CONFIG_FILE) $(DOXYGEN_SOURCES)
  436. $(DOXYGEN_COMMAND) $(DOXYGEN_CONFIG_FILE)
  437. $(EMPTY_LINT_REPORT): $(LINT_OUTPUTS) | $(BUILD_DIR)
  438. @ cat $(LINT_OUTPUTS) > $@
  439. @ if [ -s "$@" ]; then \
  440. cat $@; \
  441. mv $@ $(NONEMPTY_LINT_REPORT); \
  442. echo "Found one or more lint errors."; \
  443. exit 1; \
  444. fi; \
  445. $(RM) $(NONEMPTY_LINT_REPORT); \
  446. echo "No lint errors!";
  447. $(LINT_OUTPUTS): $(LINT_OUTPUT_DIR)/%.lint.txt : % $(LINT_SCRIPT) | $(LINT_OUTPUT_DIR)
  448. @ mkdir -p $(dir $@)
  449. @ python $(LINT_SCRIPT) $< 2>&1 \
  450. | grep -v "^Done processing " \
  451. | grep -v "^Total errors found: 0" \
  452. > $@ \
  453. || true
  454. test: $(TEST_ALL_BIN) $(TEST_ALL_DYNLINK_BIN) $(TEST_BINS)
  455. tools: $(TOOL_BINS) $(TOOL_BIN_LINKS)
  456. examples: $(EXAMPLE_BINS)
  457. py$(PROJECT): py
  458. py: $(PY$(PROJECT)_SO) $(PROTO_GEN_PY)
  459. $(PY$(PROJECT)_SO): $(PY$(PROJECT)_SRC) $(PY$(PROJECT)_HXX) | $(DYNAMIC_NAME)
  460. @ echo CXX/LD -o $@ $<
  461. $(Q)$(CXX) -shared -o $@ $(PY$(PROJECT)_SRC) \
  462. -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(PYTHON_LDFLAGS) \
  463. -Wl,-rpath,$(ORIGIN)/../../build/lib
  464. mat$(PROJECT): mat
  465. mat: $(MAT$(PROJECT)_SO)
  466. $(MAT$(PROJECT)_SO): $(MAT$(PROJECT)_SRC) $(STATIC_NAME)
  467. @ if [ -z "$(MATLAB_DIR)" ]; then \
  468. echo "MATLAB_DIR must be specified in $(CONFIG_FILE)" \
  469. "to build mat$(PROJECT)."; \
  470. exit 1; \
  471. fi
  472. @ echo MEX $<
  473. $(Q)$(MATLAB_DIR)/bin/mex $(MAT$(PROJECT)_SRC) \
  474. CXX="$(CXX)" \
  475. CXXFLAGS="\$$CXXFLAGS $(MATLAB_CXXFLAGS)" \
  476. CXXLIBS="\$$CXXLIBS $(STATIC_LINK_COMMAND) $(LDFLAGS)" -output $@
  477. @ if [ -f "$(PROJECT)_.d" ]; then \
  478. mv -f $(PROJECT)_.d $(BUILD_DIR)/${MAT$(PROJECT)_SO:.$(MAT_SO_EXT)=.d}; \
  479. fi
  480. runtest: $(TEST_ALL_BIN)
  481. $(TOOL_BUILD_DIR)/caffe
  482. $(TEST_ALL_BIN) $(TEST_GPUID) --gtest_shuffle $(TEST_FILTER)
  483. pytest: py
  484. cd python; python -m unittest discover -s caffe/test
  485. mattest: mat
  486. cd matlab; $(MATLAB_DIR)/bin/matlab -nodisplay -r 'caffe.run_tests(), exit()'
  487. warn: $(EMPTY_WARN_REPORT)
  488. $(EMPTY_WARN_REPORT): $(ALL_WARNS) | $(BUILD_DIR)
  489. @ cat $(ALL_WARNS) > $@
  490. @ if [ -s "$@" ]; then \
  491. cat $@; \
  492. mv $@ $(NONEMPTY_WARN_REPORT); \
  493. echo "Compiler produced one or more warnings."; \
  494. exit 1; \
  495. fi; \
  496. $(RM) $(NONEMPTY_WARN_REPORT); \
  497. echo "No compiler warnings!";
  498. $(ALL_WARNS): %.o.$(WARNS_EXT) : %.o
  499. $(BUILD_DIR_LINK): $(BUILD_DIR)/.linked
  500. # Create a target ".linked" in this BUILD_DIR to tell Make that the "build" link
  501. # is currently correct, then delete the one in the OTHER_BUILD_DIR in case it
  502. # exists and $(DEBUG) is toggled later.
  503. $(BUILD_DIR)/.linked:
  504. @ mkdir -p $(BUILD_DIR)
  505. @ $(RM) $(OTHER_BUILD_DIR)/.linked
  506. @ $(RM) -r $(BUILD_DIR_LINK)
  507. @ ln -s $(BUILD_DIR) $(BUILD_DIR_LINK)
  508. @ touch $@
  509. $(ALL_BUILD_DIRS): | $(BUILD_DIR_LINK)
  510. @ mkdir -p $@
  511. $(DYNAMIC_NAME): $(OBJS) | $(LIB_BUILD_DIR)
  512. @ echo LD -o $@
  513. $(Q)$(CXX) -shared -o $@ $(OBJS) $(VERSIONFLAGS) $(LINKFLAGS) $(LDFLAGS)
  514. @ cd $(BUILD_DIR)/lib; rm -f $(DYNAMIC_NAME_SHORT); ln -s $(DYNAMIC_VERSIONED_NAME_SHORT) $(DYNAMIC_NAME_SHORT)
  515. $(STATIC_NAME): $(OBJS) | $(LIB_BUILD_DIR)
  516. @ echo AR -o $@
  517. $(Q)ar rcs $@ $(OBJS)
  518. $(BUILD_DIR)/%.o: %.cpp $(PROTO_GEN_HEADER) | $(ALL_BUILD_DIRS)
  519. @ echo CXX $<
  520. $(Q)$(CXX) $< $(CXXFLAGS) -c -o $@ 2> $@.$(WARNS_EXT) \
  521. || (cat $@.$(WARNS_EXT); exit 1)
  522. @ cat $@.$(WARNS_EXT)
  523. $(PROTO_BUILD_DIR)/%.pb.o: $(PROTO_BUILD_DIR)/%.pb.cc $(PROTO_GEN_HEADER) \
  524. | $(PROTO_BUILD_DIR)
  525. @ echo CXX $<
  526. $(Q)$(CXX) $< $(CXXFLAGS) -c -o $@ 2> $@.$(WARNS_EXT) \
  527. || (cat $@.$(WARNS_EXT); exit 1)
  528. @ cat $@.$(WARNS_EXT)
  529. $(BUILD_DIR)/cuda/%.o: %.cu | $(ALL_BUILD_DIRS)
  530. @ echo NVCC $<
  531. $(Q)$(CUDA_DIR)/bin/nvcc $(NVCCFLAGS) $(CUDA_ARCH) -M $< -o ${@:.o=.d} \
  532. -odir $(@D)
  533. $(Q)$(CUDA_DIR)/bin/nvcc $(NVCCFLAGS) $(CUDA_ARCH) -c $< -o $@ 2> $@.$(WARNS_EXT) \
  534. || (cat $@.$(WARNS_EXT); exit 1)
  535. @ cat $@.$(WARNS_EXT)
  536. $(TEST_ALL_BIN): $(TEST_MAIN_SRC) $(TEST_OBJS) $(GTEST_OBJ) \
  537. | $(DYNAMIC_NAME) $(TEST_BIN_DIR)
  538. @ echo CXX/LD -o $@ $<
  539. $(Q)$(CXX) $(TEST_MAIN_SRC) $(TEST_OBJS) $(GTEST_OBJ) \
  540. -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib
  541. $(TEST_CU_BINS): $(TEST_BIN_DIR)/%.testbin: $(TEST_CU_BUILD_DIR)/%.o \
  542. $(GTEST_OBJ) | $(DYNAMIC_NAME) $(TEST_BIN_DIR)
  543. @ echo LD $<
  544. $(Q)$(CXX) $(TEST_MAIN_SRC) $< $(GTEST_OBJ) \
  545. -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib
  546. $(TEST_CXX_BINS): $(TEST_BIN_DIR)/%.testbin: $(TEST_CXX_BUILD_DIR)/%.o \
  547. $(GTEST_OBJ) | $(DYNAMIC_NAME) $(TEST_BIN_DIR)
  548. @ echo LD $<
  549. $(Q)$(CXX) $(TEST_MAIN_SRC) $< $(GTEST_OBJ) \
  550. -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib
  551. # Target for extension-less symlinks to tool binaries with extension '*.bin'.
  552. $(TOOL_BUILD_DIR)/%: $(TOOL_BUILD_DIR)/%.bin | $(TOOL_BUILD_DIR)
  553. @ $(RM) $@
  554. @ ln -s $(notdir $<) $@
  555. $(TOOL_BINS): %.bin : %.o | $(DYNAMIC_NAME)
  556. @ echo CXX/LD -o $@
  557. $(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(LDFLAGS) \
  558. -Wl,-rpath,$(ORIGIN)/../lib
  559. $(EXAMPLE_BINS): %.bin : %.o | $(DYNAMIC_NAME)
  560. @ echo CXX/LD -o $@
  561. $(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(LDFLAGS) \
  562. -Wl,-rpath,$(ORIGIN)/../../lib
  563. proto: $(PROTO_GEN_CC) $(PROTO_GEN_HEADER)
  564. $(PROTO_BUILD_DIR)/%.pb.cc $(PROTO_BUILD_DIR)/%.pb.h : \
  565. $(PROTO_SRC_DIR)/%.proto | $(PROTO_BUILD_DIR)
  566. @ echo PROTOC $<
  567. $(Q)protoc --proto_path=$(PROTO_SRC_DIR) --cpp_out=$(PROTO_BUILD_DIR) $<
  568. $(PY_PROTO_BUILD_DIR)/%_pb2.py : $(PROTO_SRC_DIR)/%.proto \
  569. $(PY_PROTO_INIT) | $(PY_PROTO_BUILD_DIR)
  570. @ echo PROTOC \(python\) $<
  571. $(Q)protoc --proto_path=src --python_out=python $<
  572. $(PY_PROTO_INIT): | $(PY_PROTO_BUILD_DIR)
  573. touch $(PY_PROTO_INIT)
  574. clean:
  575. @- $(RM) -rf $(ALL_BUILD_DIRS)
  576. @- $(RM) -rf $(OTHER_BUILD_DIR)
  577. @- $(RM) -rf $(BUILD_DIR_LINK)
  578. @- $(RM) -rf $(DISTRIBUTE_DIR)
  579. @- $(RM) $(PY$(PROJECT)_SO)
  580. @- $(RM) $(MAT$(PROJECT)_SO)
  581. supercleanfiles:
  582. $(eval SUPERCLEAN_FILES := $(strip \
  583. $(foreach ext,$(SUPERCLEAN_EXTS), $(shell find . -name '*$(ext)' \
  584. -not -path './data/*'))))
  585. supercleanlist: supercleanfiles
  586. @ \
  587. if [ -z "$(SUPERCLEAN_FILES)" ]; then \
  588. echo "No generated files found."; \
  589. else \
  590. echo $(SUPERCLEAN_FILES) | tr ' ' '\n'; \
  591. fi
  592. superclean: clean supercleanfiles
  593. @ \
  594. if [ -z "$(SUPERCLEAN_FILES)" ]; then \
  595. echo "No generated files found."; \
  596. else \
  597. echo "Deleting the following generated files:"; \
  598. echo $(SUPERCLEAN_FILES) | tr ' ' '\n'; \
  599. $(RM) $(SUPERCLEAN_FILES); \
  600. fi
  601. $(DIST_ALIASES): $(DISTRIBUTE_DIR)
  602. $(DISTRIBUTE_DIR): all py | $(DISTRIBUTE_SUBDIRS)
  603. # add proto
  604. cp -r src/caffe/proto $(DISTRIBUTE_DIR)/
  605. # add include
  606. cp -r include $(DISTRIBUTE_DIR)/
  607. mkdir -p $(DISTRIBUTE_DIR)/include/caffe/proto
  608. cp $(PROTO_GEN_HEADER_SRCS) $(DISTRIBUTE_DIR)/include/caffe/proto
  609. # add tool and example binaries
  610. cp $(TOOL_BINS) $(DISTRIBUTE_DIR)/bin
  611. cp $(EXAMPLE_BINS) $(DISTRIBUTE_DIR)/bin
  612. # add libraries
  613. cp $(STATIC_NAME) $(DISTRIBUTE_DIR)/lib
  614. install -m 644 $(DYNAMIC_NAME) $(DISTRIBUTE_DIR)/lib
  615. cd $(DISTRIBUTE_DIR)/lib; rm -f $(DYNAMIC_NAME_SHORT); ln -s $(DYNAMIC_VERSIONED_NAME_SHORT) $(DYNAMIC_NAME_SHORT)
  616. # add python - it's not the standard way, indeed...
  617. cp -r python $(DISTRIBUTE_DIR)/
  618. -include $(DEPS)
cd python/

使用阿里云镜像安装依赖库:

for req in $(cat requirements.txt); do pip3 install $req -i https://mirrors.aliyun.com/pypi/simple/; done 
cd .. && sudo make clean
sudo make all -j16

 由于caffe最后支持的版本是cuDNN7.6.5,为了能在cuDNN8的环境下编译通过,需要修改两个cpp文件,路径为/caffe/src/caffe/layers下的cudnn_conv_layer.cpp和cudnn_deconv_layer.cpp两个文件,分别将他们内容替换为:

  1. /**
  2. * @File Name : cudnn_conv_layer.cpp
  3. */
  4. #ifdef USE_CUDNN
  5. #include <algorithm>
  6. #include <vector>
  7. #include "caffe/layers/cudnn_conv_layer.hpp"
  8. namespace caffe
  9. {
  10. // Set to three for the benefit of the backward pass, which
  11. // can use separate streams for calculating the gradient w.r.t.
  12. // bias, filter weights, and bottom data for each group independently
  13. #define CUDNN_STREAMS_PER_GROUP 3
  14. /**
  15. * TODO(dox) explain cuDNN interface
  16. */
  17. template <typename Dtype>
  18. void CuDNNConvolutionLayer<Dtype>::LayerSetUp(
  19. const vector<Blob<Dtype> *> &bottom, const vector<Blob<Dtype> *> &top)
  20. {
  21. ConvolutionLayer<Dtype>::LayerSetUp(bottom, top);
  22. // Initialize CUDA streams and cuDNN.
  23. stream_ = new cudaStream_t[this->group_ * CUDNN_STREAMS_PER_GROUP];
  24. handle_ = new cudnnHandle_t[this->group_ * CUDNN_STREAMS_PER_GROUP];
  25. // Initialize algorithm arrays
  26. fwd_algo_ = new cudnnConvolutionFwdAlgo_t[bottom.size()];
  27. bwd_filter_algo_ = new cudnnConvolutionBwdFilterAlgo_t[bottom.size()];
  28. bwd_data_algo_ = new cudnnConvolutionBwdDataAlgo_t[bottom.size()];
  29. // initialize size arrays
  30. workspace_fwd_sizes_ = new size_t[bottom.size()];
  31. workspace_bwd_filter_sizes_ = new size_t[bottom.size()];
  32. workspace_bwd_data_sizes_ = new size_t[bottom.size()];
  33. // workspace data
  34. workspaceSizeInBytes = 0;
  35. workspaceData = NULL;
  36. workspace = new void *[this->group_ * CUDNN_STREAMS_PER_GROUP];
  37. for (size_t i = 0; i < bottom.size(); ++i)
  38. {
  39. // initialize all to default algorithms
  40. fwd_algo_[i] = (cudnnConvolutionFwdAlgo_t)0;
  41. bwd_filter_algo_[i] = (cudnnConvolutionBwdFilterAlgo_t)0;
  42. bwd_data_algo_[i] = (cudnnConvolutionBwdDataAlgo_t)0;
  43. // default algorithms don't require workspace
  44. workspace_fwd_sizes_[i] = 0;
  45. workspace_bwd_data_sizes_[i] = 0;
  46. workspace_bwd_filter_sizes_[i] = 0;
  47. }
  48. for (int g = 0; g < this->group_ * CUDNN_STREAMS_PER_GROUP; g++)
  49. {
  50. CUDA_CHECK(cudaStreamCreate(&stream_[g]));
  51. CUDNN_CHECK(cudnnCreate(&handle_[g]));
  52. CUDNN_CHECK(cudnnSetStream(handle_[g], stream_[g]));
  53. workspace[g] = NULL;
  54. }
  55. // Set the indexing parameters.
  56. bias_offset_ = (this->num_output_ / this->group_);
  57. // Create filter descriptor.
  58. const int *kernel_shape_data = this->kernel_shape_.cpu_data();
  59. const int kernel_h = kernel_shape_data[0];
  60. const int kernel_w = kernel_shape_data[1];
  61. cudnn::createFilterDesc<Dtype>(&filter_desc_,
  62. this->num_output_ / this->group_, this->channels_ / this->group_,
  63. kernel_h, kernel_w);
  64. // Create tensor descriptor(s) for data and corresponding convolution(s).
  65. for (int i = 0; i < bottom.size(); i++)
  66. {
  67. cudnnTensorDescriptor_t bottom_desc;
  68. cudnn::createTensor4dDesc<Dtype>(&bottom_desc);
  69. bottom_descs_.push_back(bottom_desc);
  70. cudnnTensorDescriptor_t top_desc;
  71. cudnn::createTensor4dDesc<Dtype>(&top_desc);
  72. top_descs_.push_back(top_desc);
  73. cudnnConvolutionDescriptor_t conv_desc;
  74. cudnn::createConvolutionDesc<Dtype>(&conv_desc);
  75. conv_descs_.push_back(conv_desc);
  76. }
  77. // Tensor descriptor for bias.
  78. if (this->bias_term_)
  79. {
  80. cudnn::createTensor4dDesc<Dtype>(&bias_desc_);
  81. }
  82. handles_setup_ = true;
  83. }
  84. template <typename Dtype>
  85. void CuDNNConvolutionLayer<Dtype>::Reshape(
  86. const vector<Blob<Dtype> *> &bottom, const vector<Blob<Dtype> *> &top)
  87. {
  88. ConvolutionLayer<Dtype>::Reshape(bottom, top);
  89. CHECK_EQ(2, this->num_spatial_axes_)
  90. << "CuDNNConvolution input must have 2 spatial axes "
  91. << "(e.g., height and width). "
  92. << "Use 'engine: CAFFE' for general ND convolution.";
  93. bottom_offset_ = this->bottom_dim_ / this->group_;
  94. top_offset_ = this->top_dim_ / this->group_;
  95. const int height = bottom[0]->shape(this->channel_axis_ + 1);
  96. const int width = bottom[0]->shape(this->channel_axis_ + 2);
  97. const int height_out = top[0]->shape(this->channel_axis_ + 1);
  98. const int width_out = top[0]->shape(this->channel_axis_ + 2);
  99. const int *pad_data = this->pad_.cpu_data();
  100. const int pad_h = pad_data[0];
  101. const int pad_w = pad_data[1];
  102. const int *stride_data = this->stride_.cpu_data();
  103. const int stride_h = stride_data[0];
  104. const int stride_w = stride_data[1];
  105. #if CUDNN_VERSION_MIN(8, 0, 0)
  106. int RetCnt;
  107. bool found_conv_algorithm;
  108. size_t free_memory, total_memory;
  109. cudnnConvolutionFwdAlgoPerf_t fwd_algo_pref_[4];
  110. cudnnConvolutionBwdDataAlgoPerf_t bwd_data_algo_pref_[4];
  111. // get memory sizes
  112. cudaMemGetInfo(&free_memory, &total_memory);
  113. #else
  114. // Specify workspace limit for kernels directly until we have a
  115. // planning strategy and a rewrite of Caffe's GPU memory mangagement
  116. size_t workspace_limit_bytes = 8 * 1024 * 1024;
  117. #endif
  118. for (int i = 0; i < bottom.size(); i++)
  119. {
  120. cudnn::setTensor4dDesc<Dtype>(&bottom_descs_[i],
  121. this->num_,
  122. this->channels_ / this->group_, height, width,
  123. this->channels_ * height * width,
  124. height * width, width, 1);
  125. cudnn::setTensor4dDesc<Dtype>(&top_descs_[i],
  126. this->num_,
  127. this->num_output_ / this->group_, height_out, width_out,
  128. this->num_output_ * this->out_spatial_dim_,
  129. this->out_spatial_dim_, width_out, 1);
  130. cudnn::setConvolutionDesc<Dtype>(&conv_descs_[i], bottom_descs_[i],
  131. filter_desc_, pad_h, pad_w,
  132. stride_h, stride_w);
  133. #if CUDNN_VERSION_MIN(8, 0, 0)
  134. // choose forward algorithm for filter
  135. // in forward filter the CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD_NONFUSED is not implemented in cuDNN 8
  136. CUDNN_CHECK(cudnnGetConvolutionForwardAlgorithm_v7(handle_[0],
  137. bottom_descs_[i],
  138. filter_desc_,
  139. conv_descs_[i],
  140. top_descs_[i],
  141. 4,
  142. &RetCnt,
  143. fwd_algo_pref_));
  144. found_conv_algorithm = false;
  145. for (int n = 0; n < RetCnt; n++)
  146. {
  147. if (fwd_algo_pref_[n].status == CUDNN_STATUS_SUCCESS &&
  148. fwd_algo_pref_[n].algo != CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD_NONFUSED &&
  149. fwd_algo_pref_[n].memory < free_memory)
  150. {
  151. found_conv_algorithm = true;
  152. fwd_algo_[i] = fwd_algo_pref_[n].algo;
  153. workspace_fwd_sizes_[i] = fwd_algo_pref_[n].memory;
  154. break;
  155. }
  156. }
  157. if (!found_conv_algorithm)
  158. LOG(ERROR) << "cuDNN did not return a suitable algorithm for convolution.";
  159. else
  160. {
  161. // choose backward algorithm for filter
  162. // for better or worse, just a fixed constant due to the missing
  163. // cudnnGetConvolutionBackwardFilterAlgorithm in cuDNN version 8.0
  164. bwd_filter_algo_[i] = CUDNN_CONVOLUTION_BWD_FILTER_ALGO_0;
  165. // twice the amount of the forward search to be save
  166. workspace_bwd_filter_sizes_[i] = 2 * workspace_fwd_sizes_[i];
  167. }
  168. // choose backward algo for data
  169. CUDNN_CHECK(cudnnGetConvolutionBackwardDataAlgorithm_v7(handle_[0],
  170. filter_desc_,
  171. top_descs_[i],
  172. conv_descs_[i],
  173. bottom_descs_[i],
  174. 4,
  175. &RetCnt,
  176. bwd_data_algo_pref_));
  177. found_conv_algorithm = false;
  178. for (int n = 0; n < RetCnt; n++)
  179. {
  180. if (bwd_data_algo_pref_[n].status == CUDNN_STATUS_SUCCESS &&
  181. bwd_data_algo_pref_[n].algo != CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD &&
  182. bwd_data_algo_pref_[n].algo != CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD_NONFUSED &&
  183. bwd_data_algo_pref_[n].memory < free_memory)
  184. {
  185. found_conv_algorithm = true;
  186. bwd_data_algo_[i] = bwd_data_algo_pref_[n].algo;
  187. workspace_bwd_data_sizes_[i] = bwd_data_algo_pref_[n].memory;
  188. break;
  189. }
  190. }
  191. if (!found_conv_algorithm)
  192. LOG(ERROR) << "cuDNN did not return a suitable algorithm for convolution.";
  193. #else
  194. // choose forward and backward algorithms + workspace(s)
  195. CUDNN_CHECK(cudnnGetConvolutionForwardAlgorithm(handle_[0],
  196. bottom_descs_[i],
  197. filter_desc_,
  198. conv_descs_[i],
  199. top_descs_[i],
  200. CUDNN_CONVOLUTION_FWD_SPECIFY_WORKSPACE_LIMIT,
  201. workspace_limit_bytes,
  202. &fwd_algo_[i]));
  203. CUDNN_CHECK(cudnnGetConvolutionForwardWorkspaceSize(handle_[0],
  204. bottom_descs_[i],
  205. filter_desc_,
  206. conv_descs_[i],
  207. top_descs_[i],
  208. fwd_algo_[i],
  209. &(workspace_fwd_sizes_[i])));
  210. // choose backward algorithm for filter
  211. CUDNN_CHECK(cudnnGetConvolutionBackwardFilterAlgorithm(handle_[0],
  212. bottom_descs_[i], top_descs_[i], conv_descs_[i], filter_desc_,
  213. CUDNN_CONVOLUTION_BWD_FILTER_SPECIFY_WORKSPACE_LIMIT,
  214. workspace_limit_bytes, &bwd_filter_algo_[i]));
  215. // get workspace for backwards filter algorithm
  216. CUDNN_CHECK(cudnnGetConvolutionBackwardFilterWorkspaceSize(handle_[0],
  217. bottom_descs_[i], top_descs_[i], conv_descs_[i], filter_desc_,
  218. bwd_filter_algo_[i], &workspace_bwd_filter_sizes_[i]));
  219. // choose backward algo for data
  220. CUDNN_CHECK(cudnnGetConvolutionBackwardDataAlgorithm(handle_[0],
  221. filter_desc_, top_descs_[i], conv_descs_[i], bottom_descs_[i],
  222. CUDNN_CONVOLUTION_BWD_DATA_SPECIFY_WORKSPACE_LIMIT,
  223. workspace_limit_bytes, &bwd_data_algo_[i]));
  224. // get workspace size
  225. CUDNN_CHECK(cudnnGetConvolutionBackwardDataWorkspaceSize(handle_[0],
  226. filter_desc_, top_descs_[i], conv_descs_[i], bottom_descs_[i],
  227. bwd_data_algo_[i], &workspace_bwd_data_sizes_[i]));
  228. #endif
  229. }
  230. // reduce over all workspace sizes to get a maximum to allocate / reallocate
  231. size_t total_workspace_fwd = 0;
  232. size_t total_workspace_bwd_data = 0;
  233. size_t total_workspace_bwd_filter = 0;
  234. for (size_t i = 0; i < bottom.size(); i++)
  235. {
  236. total_workspace_fwd = std::max(total_workspace_fwd,
  237. workspace_fwd_sizes_[i]);
  238. total_workspace_bwd_data = std::max(total_workspace_bwd_data,
  239. workspace_bwd_data_sizes_[i]);
  240. total_workspace_bwd_filter = std::max(total_workspace_bwd_filter,
  241. workspace_bwd_filter_sizes_[i]);
  242. }
  243. // get max over all operations
  244. size_t max_workspace = std::max(total_workspace_fwd,
  245. total_workspace_bwd_data);
  246. max_workspace = std::max(max_workspace, total_workspace_bwd_filter);
  247. // ensure all groups have enough workspace
  248. size_t total_max_workspace = max_workspace *
  249. (this->group_ * CUDNN_STREAMS_PER_GROUP);
  250. // this is the total amount of storage needed over all groups + streams
  251. if (total_max_workspace > workspaceSizeInBytes)
  252. {
  253. DLOG(INFO) << "Reallocating workspace storage: " << total_max_workspace;
  254. workspaceSizeInBytes = total_max_workspace;
  255. // free the existing workspace and allocate a new (larger) one
  256. cudaFree(this->workspaceData);
  257. cudaError_t err = cudaMalloc(&(this->workspaceData), workspaceSizeInBytes);
  258. if (err != cudaSuccess)
  259. {
  260. // force zero memory path
  261. for (int i = 0; i < bottom.size(); i++)
  262. {
  263. workspace_fwd_sizes_[i] = 0;
  264. workspace_bwd_filter_sizes_[i] = 0;
  265. workspace_bwd_data_sizes_[i] = 0;
  266. fwd_algo_[i] = CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_GEMM;
  267. bwd_filter_algo_[i] = CUDNN_CONVOLUTION_BWD_FILTER_ALGO_0;
  268. bwd_data_algo_[i] = CUDNN_CONVOLUTION_BWD_DATA_ALGO_0;
  269. }
  270. // NULL out all workspace pointers
  271. for (int g = 0; g < (this->group_ * CUDNN_STREAMS_PER_GROUP); g++)
  272. {
  273. workspace[g] = NULL;
  274. }
  275. // NULL out underlying data
  276. workspaceData = NULL;
  277. workspaceSizeInBytes = 0;
  278. }
  279. // if we succeed in the allocation, set pointer aliases for workspaces
  280. for (int g = 0; g < (this->group_ * CUDNN_STREAMS_PER_GROUP); g++)
  281. {
  282. workspace[g] = reinterpret_cast<char *>(workspaceData) + g * max_workspace;
  283. }
  284. }
  285. // Tensor descriptor for bias.
  286. if (this->bias_term_)
  287. {
  288. cudnn::setTensor4dDesc<Dtype>(&bias_desc_,
  289. 1, this->num_output_ / this->group_, 1, 1);
  290. }
  291. }
  292. template <typename Dtype>
  293. CuDNNConvolutionLayer<Dtype>::~CuDNNConvolutionLayer()
  294. {
  295. // Check that handles have been setup before destroying.
  296. if (!handles_setup_)
  297. {
  298. return;
  299. }
  300. for (int i = 0; i < bottom_descs_.size(); i++)
  301. {
  302. cudnnDestroyTensorDescriptor(bottom_descs_[i]);
  303. cudnnDestroyTensorDescriptor(top_descs_[i]);
  304. cudnnDestroyConvolutionDescriptor(conv_descs_[i]);
  305. }
  306. if (this->bias_term_)
  307. {
  308. cudnnDestroyTensorDescriptor(bias_desc_);
  309. }
  310. cudnnDestroyFilterDescriptor(filter_desc_);
  311. for (int g = 0; g < this->group_ * CUDNN_STREAMS_PER_GROUP; g++)
  312. {
  313. cudaStreamDestroy(stream_[g]);
  314. cudnnDestroy(handle_[g]);
  315. }
  316. cudaFree(workspaceData);
  317. delete[] stream_;
  318. delete[] handle_;
  319. delete[] fwd_algo_;
  320. delete[] bwd_filter_algo_;
  321. delete[] bwd_data_algo_;
  322. delete[] workspace_fwd_sizes_;
  323. delete[] workspace_bwd_data_sizes_;
  324. delete[] workspace_bwd_filter_sizes_;
  325. }
  326. INSTANTIATE_CLASS(CuDNNConvolutionLayer);
  327. } // namespace caffe
  328. #endif
  1. /**
  2. * @File Name : cudnn_deconv_layer.cpp
  3. */
  4. #ifdef USE_CUDNN
  5. #include <algorithm>
  6. #include <vector>
  7. #include "caffe/layers/cudnn_deconv_layer.hpp"
  8. namespace caffe
  9. {
  10. // Set to three for the benefit of the backward pass, which
  11. // can use separate streams for calculating the gradient w.r.t.
  12. // bias, filter weights, and bottom data for each group independently
  13. #define CUDNN_STREAMS_PER_GROUP 3
  14. /**
  15. * TODO(dox) explain cuDNN interface
  16. */
  17. template <typename Dtype>
  18. void CuDNNDeconvolutionLayer<Dtype>::LayerSetUp(
  19. const vector<Blob<Dtype> *> &bottom, const vector<Blob<Dtype> *> &top)
  20. {
  21. DeconvolutionLayer<Dtype>::LayerSetUp(bottom, top);
  22. // Initialize CUDA streams and cuDNN.
  23. stream_ = new cudaStream_t[this->group_ * CUDNN_STREAMS_PER_GROUP];
  24. handle_ = new cudnnHandle_t[this->group_ * CUDNN_STREAMS_PER_GROUP];
  25. // Initialize algorithm arrays
  26. fwd_algo_ = new cudnnConvolutionFwdAlgo_t[bottom.size()];
  27. bwd_filter_algo_ = new cudnnConvolutionBwdFilterAlgo_t[bottom.size()];
  28. bwd_data_algo_ = new cudnnConvolutionBwdDataAlgo_t[bottom.size()];
  29. // initialize size arrays
  30. workspace_fwd_sizes_ = new size_t[bottom.size()];
  31. workspace_bwd_filter_sizes_ = new size_t[bottom.size()];
  32. workspace_bwd_data_sizes_ = new size_t[bottom.size()];
  33. // workspace data
  34. workspaceSizeInBytes = 0;
  35. workspaceData = NULL;
  36. workspace = new void *[this->group_ * CUDNN_STREAMS_PER_GROUP];
  37. for (size_t i = 0; i < bottom.size(); ++i)
  38. {
  39. // initialize all to default algorithms
  40. fwd_algo_[i] = (cudnnConvolutionFwdAlgo_t)0;
  41. bwd_filter_algo_[i] = (cudnnConvolutionBwdFilterAlgo_t)0;
  42. bwd_data_algo_[i] = (cudnnConvolutionBwdDataAlgo_t)0;
  43. // default algorithms don't require workspace
  44. workspace_fwd_sizes_[i] = 0;
  45. workspace_bwd_data_sizes_[i] = 0;
  46. workspace_bwd_filter_sizes_[i] = 0;
  47. }
  48. for (int g = 0; g < this->group_ * CUDNN_STREAMS_PER_GROUP; g++)
  49. {
  50. CUDA_CHECK(cudaStreamCreate(&stream_[g]));
  51. CUDNN_CHECK(cudnnCreate(&handle_[g]));
  52. CUDNN_CHECK(cudnnSetStream(handle_[g], stream_[g]));
  53. workspace[g] = NULL;
  54. }
  55. // Set the indexing parameters.
  56. bias_offset_ = (this->num_output_ / this->group_);
  57. // Create filter descriptor.
  58. const int *kernel_shape_data = this->kernel_shape_.cpu_data();
  59. const int kernel_h = kernel_shape_data[0];
  60. const int kernel_w = kernel_shape_data[1];
  61. cudnn::createFilterDesc<Dtype>(&filter_desc_,
  62. this->channels_ / this->group_,
  63. this->num_output_ / this->group_,
  64. kernel_h,
  65. kernel_w);
  66. // Create tensor descriptor(s) for data and corresponding convolution(s).
  67. for (int i = 0; i < bottom.size(); i++)
  68. {
  69. cudnnTensorDescriptor_t bottom_desc;
  70. cudnn::createTensor4dDesc<Dtype>(&bottom_desc);
  71. bottom_descs_.push_back(bottom_desc);
  72. cudnnTensorDescriptor_t top_desc;
  73. cudnn::createTensor4dDesc<Dtype>(&top_desc);
  74. top_descs_.push_back(top_desc);
  75. cudnnConvolutionDescriptor_t conv_desc;
  76. cudnn::createConvolutionDesc<Dtype>(&conv_desc);
  77. conv_descs_.push_back(conv_desc);
  78. }
  79. // Tensor descriptor for bias.
  80. if (this->bias_term_)
  81. {
  82. cudnn::createTensor4dDesc<Dtype>(&bias_desc_);
  83. }
  84. handles_setup_ = true;
  85. }
  86. template <typename Dtype>
  87. void CuDNNDeconvolutionLayer<Dtype>::Reshape(
  88. const vector<Blob<Dtype> *> &bottom, const vector<Blob<Dtype> *> &top)
  89. {
  90. DeconvolutionLayer<Dtype>::Reshape(bottom, top);
  91. CHECK_EQ(2, this->num_spatial_axes_)
  92. << "CuDNNDeconvolutionLayer input must have 2 spatial axes "
  93. << "(e.g., height and width). "
  94. << "Use 'engine: CAFFE' for general ND convolution.";
  95. bottom_offset_ = this->bottom_dim_ / this->group_;
  96. top_offset_ = this->top_dim_ / this->group_;
  97. const int height = bottom[0]->shape(this->channel_axis_ + 1);
  98. const int width = bottom[0]->shape(this->channel_axis_ + 2);
  99. const int height_out = top[0]->shape(this->channel_axis_ + 1);
  100. const int width_out = top[0]->shape(this->channel_axis_ + 2);
  101. const int *pad_data = this->pad_.cpu_data();
  102. const int pad_h = pad_data[0];
  103. const int pad_w = pad_data[1];
  104. const int *stride_data = this->stride_.cpu_data();
  105. const int stride_h = stride_data[0];
  106. const int stride_w = stride_data[1];
  107. #if CUDNN_VERSION_MIN(8, 0, 0)
  108. int RetCnt;
  109. bool found_conv_algorithm;
  110. size_t free_memory, total_memory;
  111. cudnnConvolutionFwdAlgoPerf_t fwd_algo_pref_[4];
  112. cudnnConvolutionBwdDataAlgoPerf_t bwd_data_algo_pref_[4];
  113. // get memory sizes
  114. cudaMemGetInfo(&free_memory, &total_memory);
  115. #else
  116. // Specify workspace limit for kernels directly until we have a
  117. // planning strategy and a rewrite of Caffe's GPU memory mangagement
  118. size_t workspace_limit_bytes = 8 * 1024 * 1024;
  119. #endif
  120. for (int i = 0; i < bottom.size(); i++)
  121. {
  122. cudnn::setTensor4dDesc<Dtype>(&bottom_descs_[i],
  123. this->num_,
  124. this->channels_ / this->group_,
  125. height,
  126. width,
  127. this->channels_ * height * width,
  128. height * width,
  129. width,
  130. 1);
  131. cudnn::setTensor4dDesc<Dtype>(&top_descs_[i],
  132. this->num_,
  133. this->num_output_ / this->group_,
  134. height_out,
  135. width_out,
  136. this->num_output_ * height_out * width_out,
  137. height_out * width_out,
  138. width_out,
  139. 1);
  140. cudnn::setConvolutionDesc<Dtype>(&conv_descs_[i],
  141. top_descs_[i],
  142. filter_desc_,
  143. pad_h,
  144. pad_w,
  145. stride_h,
  146. stride_w);
  147. #if CUDNN_VERSION_MIN(8, 0, 0)
  148. // choose forward algorithm for filter
  149. // in forward filter the CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD_NONFUSED is not implemented in cuDNN 8
  150. CUDNN_CHECK(cudnnGetConvolutionForwardAlgorithm_v7(handle_[0],
  151. top_descs_[i],
  152. filter_desc_,
  153. conv_descs_[i],
  154. bottom_descs_[i],
  155. 4,
  156. &RetCnt,
  157. fwd_algo_pref_));
  158. found_conv_algorithm = false;
  159. for (int n = 0; n < RetCnt; n++)
  160. {
  161. if (fwd_algo_pref_[n].status == CUDNN_STATUS_SUCCESS &&
  162. fwd_algo_pref_[n].algo != CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD_NONFUSED &&
  163. fwd_algo_pref_[n].memory < free_memory)
  164. {
  165. found_conv_algorithm = true;
  166. fwd_algo_[i] = fwd_algo_pref_[n].algo;
  167. workspace_fwd_sizes_[i] = fwd_algo_pref_[n].memory;
  168. break;
  169. }
  170. }
  171. if (!found_conv_algorithm)
  172. LOG(ERROR) << "cuDNN did not return a suitable algorithm for convolution.";
  173. else
  174. {
  175. // choose backward algorithm for filter
  176. // for better or worse, just a fixed constant due to the missing
  177. // cudnnGetConvolutionBackwardFilterAlgorithm in cuDNN version 8.0
  178. bwd_filter_algo_[i] = CUDNN_CONVOLUTION_BWD_FILTER_ALGO_0;
  179. // twice the amount of the forward search to be save
  180. workspace_bwd_filter_sizes_[i] = 2 * workspace_fwd_sizes_[i];
  181. }
  182. // choose backward algo for data
  183. CUDNN_CHECK(cudnnGetConvolutionBackwardDataAlgorithm_v7(handle_[0],
  184. filter_desc_,
  185. bottom_descs_[i],
  186. conv_descs_[i],
  187. top_descs_[i],
  188. 4,
  189. &RetCnt,
  190. bwd_data_algo_pref_));
  191. found_conv_algorithm = false;
  192. for (int n = 0; n < RetCnt; n++)
  193. {
  194. if (bwd_data_algo_pref_[n].status == CUDNN_STATUS_SUCCESS &&
  195. bwd_data_algo_pref_[n].algo != CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD &&
  196. bwd_data_algo_pref_[n].algo != CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD_NONFUSED &&
  197. bwd_data_algo_pref_[n].memory < free_memory)
  198. {
  199. found_conv_algorithm = true;
  200. bwd_data_algo_[i] = bwd_data_algo_pref_[n].algo;
  201. workspace_bwd_data_sizes_[i] = bwd_data_algo_pref_[n].memory;
  202. break;
  203. }
  204. }
  205. if (!found_conv_algorithm)
  206. LOG(ERROR) << "cuDNN did not return a suitable algorithm for convolution.";
  207. #else
  208. // choose forward and backward algorithms + workspace(s)
  209. CUDNN_CHECK(cudnnGetConvolutionForwardAlgorithm(
  210. handle_[0],
  211. top_descs_[i],
  212. filter_desc_,
  213. conv_descs_[i],
  214. bottom_descs_[i],
  215. CUDNN_CONVOLUTION_FWD_SPECIFY_WORKSPACE_LIMIT,
  216. workspace_limit_bytes,
  217. &fwd_algo_[i]));
  218. // We have found that CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_PRECOMP_GEMM is
  219. // buggy. Thus, if this algo was chosen, choose winograd instead. If
  220. // winograd is not supported or workspace is larger than threshold, choose
  221. // implicit_gemm instead.
  222. if (fwd_algo_[i] == CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_PRECOMP_GEMM)
  223. {
  224. size_t winograd_workspace_size;
  225. cudnnStatus_t status = cudnnGetConvolutionForwardWorkspaceSize(
  226. handle_[0],
  227. top_descs_[i],
  228. filter_desc_,
  229. conv_descs_[i],
  230. bottom_descs_[i],
  231. CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD,
  232. &winograd_workspace_size);
  233. if (status != CUDNN_STATUS_SUCCESS ||
  234. winograd_workspace_size >= workspace_limit_bytes)
  235. {
  236. fwd_algo_[i] = CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_GEMM;
  237. }
  238. else
  239. {
  240. fwd_algo_[i] = CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD;
  241. }
  242. }
  243. CUDNN_CHECK(cudnnGetConvolutionForwardWorkspaceSize(
  244. handle_[0],
  245. top_descs_[i],
  246. filter_desc_,
  247. conv_descs_[i],
  248. bottom_descs_[i],
  249. fwd_algo_[i],
  250. &(workspace_fwd_sizes_[i])));
  251. // choose backward algorithm for filter
  252. CUDNN_CHECK(cudnnGetConvolutionBackwardFilterAlgorithm(
  253. handle_[0],
  254. top_descs_[i],
  255. bottom_descs_[i],
  256. conv_descs_[i],
  257. filter_desc_,
  258. CUDNN_CONVOLUTION_BWD_FILTER_SPECIFY_WORKSPACE_LIMIT,
  259. workspace_limit_bytes,
  260. &bwd_filter_algo_[i]));
  261. // get workspace for backwards filter algorithm
  262. CUDNN_CHECK(cudnnGetConvolutionBackwardFilterWorkspaceSize(
  263. handle_[0],
  264. top_descs_[i],
  265. bottom_descs_[i],
  266. conv_descs_[i],
  267. filter_desc_,
  268. bwd_filter_algo_[i],
  269. &workspace_bwd_filter_sizes_[i]));
  270. // choose backward algo for data
  271. CUDNN_CHECK(cudnnGetConvolutionBackwardDataAlgorithm(
  272. handle_[0],
  273. filter_desc_,
  274. bottom_descs_[i],
  275. conv_descs_[i],
  276. top_descs_[i],
  277. CUDNN_CONVOLUTION_BWD_DATA_SPECIFY_WORKSPACE_LIMIT,
  278. workspace_limit_bytes,
  279. &bwd_data_algo_[i]));
  280. // get workspace size
  281. CUDNN_CHECK(cudnnGetConvolutionBackwardDataWorkspaceSize(
  282. handle_[0],
  283. filter_desc_,
  284. bottom_descs_[i],
  285. conv_descs_[i],
  286. top_descs_[i],
  287. bwd_data_algo_[i],
  288. &workspace_bwd_data_sizes_[i]));
  289. #endif
  290. }
  291. // reduce over all workspace sizes to get a maximum to allocate / reallocate
  292. size_t total_workspace_fwd = 0;
  293. size_t total_workspace_bwd_data = 0;
  294. size_t total_workspace_bwd_filter = 0;
  295. for (size_t i = 0; i < bottom.size(); i++)
  296. {
  297. total_workspace_fwd = std::max(total_workspace_fwd,
  298. workspace_fwd_sizes_[i]);
  299. total_workspace_bwd_data = std::max(total_workspace_bwd_data,
  300. workspace_bwd_data_sizes_[i]);
  301. total_workspace_bwd_filter = std::max(total_workspace_bwd_filter,
  302. workspace_bwd_filter_sizes_[i]);
  303. }
  304. // get max over all operations
  305. size_t max_workspace = std::max(total_workspace_fwd,
  306. total_workspace_bwd_data);
  307. max_workspace = std::max(max_workspace, total_workspace_bwd_filter);
  308. // ensure all groups have enough workspace
  309. size_t total_max_workspace = max_workspace *
  310. (this->group_ * CUDNN_STREAMS_PER_GROUP);
  311. // this is the total amount of storage needed over all groups + streams
  312. if (total_max_workspace > workspaceSizeInBytes)
  313. {
  314. DLOG(INFO) << "Reallocating workspace storage: " << total_max_workspace;
  315. workspaceSizeInBytes = total_max_workspace;
  316. // free the existing workspace and allocate a new (larger) one
  317. cudaFree(this->workspaceData);
  318. cudaError_t err = cudaMalloc(&(this->workspaceData), workspaceSizeInBytes);
  319. if (err != cudaSuccess)
  320. {
  321. // force zero memory path
  322. for (int i = 0; i < bottom.size(); i++)
  323. {
  324. workspace_fwd_sizes_[i] = 0;
  325. workspace_bwd_filter_sizes_[i] = 0;
  326. workspace_bwd_data_sizes_[i] = 0;
  327. fwd_algo_[i] = CUDNN_CONVOLUTION_FWD_ALGO_FFT_TILING;
  328. bwd_filter_algo_[i] = CUDNN_CONVOLUTION_BWD_FILTER_ALGO_0;
  329. bwd_data_algo_[i] = CUDNN_CONVOLUTION_BWD_DATA_ALGO_0;
  330. }
  331. // NULL out all workspace pointers
  332. for (int g = 0; g < (this->group_ * CUDNN_STREAMS_PER_GROUP); g++)
  333. {
  334. workspace[g] = NULL;
  335. }
  336. // NULL out underlying data
  337. workspaceData = NULL;
  338. workspaceSizeInBytes = 0;
  339. }
  340. // if we succeed in the allocation, set pointer aliases for workspaces
  341. for (int g = 0; g < (this->group_ * CUDNN_STREAMS_PER_GROUP); g++)
  342. {
  343. workspace[g] = reinterpret_cast<char *>(workspaceData) + g * max_workspace;
  344. }
  345. }
  346. // Tensor descriptor for bias.
  347. if (this->bias_term_)
  348. {
  349. cudnn::setTensor4dDesc<Dtype>(
  350. &bias_desc_, 1, this->num_output_ / this->group_, 1, 1);
  351. }
  352. }
  353. template <typename Dtype>
  354. CuDNNDeconvolutionLayer<Dtype>::~CuDNNDeconvolutionLayer()
  355. {
  356. // Check that handles have been setup before destroying.
  357. if (!handles_setup_)
  358. {
  359. return;
  360. }
  361. for (int i = 0; i < bottom_descs_.size(); i++)
  362. {
  363. cudnnDestroyTensorDescriptor(bottom_descs_[i]);
  364. cudnnDestroyTensorDescriptor(top_descs_[i]);
  365. cudnnDestroyConvolutionDescriptor(conv_descs_[i]);
  366. }
  367. if (this->bias_term_)
  368. {
  369. cudnnDestroyTensorDescriptor(bias_desc_);
  370. }
  371. cudnnDestroyFilterDescriptor(filter_desc_);
  372. for (int g = 0; g < this->group_ * CUDNN_STREAMS_PER_GROUP; g++)
  373. {
  374. cudaStreamDestroy(stream_[g]);
  375. cudnnDestroy(handle_[g]);
  376. }
  377. cudaFree(workspaceData);
  378. delete[] workspace;
  379. delete[] stream_;
  380. delete[] handle_;
  381. delete[] fwd_algo_;
  382. delete[] bwd_filter_algo_;
  383. delete[] bwd_data_algo_;
  384. delete[] workspace_fwd_sizes_;
  385. delete[] workspace_bwd_data_sizes_;
  386. delete[] workspace_bwd_filter_sizes_;
  387. }
  388. INSTANTIATE_CLASS(CuDNNDeconvolutionLayer);
  389. } // namespace caffe
  390. #endif

 由于cuDNN对代码进行了改版,在cudnn.h文件中不再指出cudnn的版本号,而是放在了cudnn_version.h文件中,所以,将cudnn_version.h中对于版本段的代码复制到cudnn.h文件中,代码如下:

locate cudnn_version.h
sudo gedit /usr/local/cuda-11.4/targets/x86_64-linux/include/cudnn_version.h

 

 复制其中的非注释部分:

sudo gedit /usr/local/cuda-11.4/targets/x86_64-linux/include/cudnn.h

粘贴到最开头:

 然后打开caffe包下的cudnn.hpp文件并指定cudnn.h路径:

 之后重新执行编译:

sudo make clean && make all -j16

生成以下静态库和共享库文件:

 测试,时间较慢,耐心等待~

sudo make test -j16
sudo make runtest -j16
sudo make pycaffe -j16

 可能会有报错,但问题不大,我们只是需要那些库文件~

24.安装libfreenect2

git clone https://github.com/OpenKinect/libfreenect2.git
cd libfreenect2 && mkdir build && cd build/
cmake -j16 .. -DENABLE_CXX11=ON 
sudo make -j16

sudo make install

sudo cp ../platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/

25.安装vtk8.2.0及PCL1.9.1

https://vtk.org/download/icon-default.png?t=N7T8https://vtk.org/download/下载VTK-8.2.0.zip

 解压之后,进入文件夹打开终端:

mkdir build && cd  build && cmake-gui

 

 单击Configure后勾选以下两项后单击Configure和Generate

 

 

sudo make -j16

sudo make install

接下来安装pcl:

git clone -b pcl-1.9.1 https://gitee.com/yubaoliu/pcl.git pcl-1.9.1

之后进入文件夹打开终端输入:

mkdir release && cd release
cmake -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_PREFIX=/usr \ -DBUILD_GPU=ON-DBUILD_apps=ON -DBUILD_examples=ON \ -DCMAKE_INSTALL_PREFIX=/usr ..

sudo make -j16

sudo make install

26.安装CarlaUE4(必须是Carla的UE仓库里的carla分支才可以通过安装Carla时的编译)

find . -name "*.sh" -exec dos2unix {} +
find . -name "*.sh" -exec chmod +x {} +
sudo chown -R m0rtzz: *

 若报错:

 因Epic更新了gitdeps,但Github上却没有更新,所以需要进入Github官方仓库release界面寻找对应版本的Commit.gitdeps.xml替换原来的文件即可:

https://github.com/EpicGames/UnrealEngine/releases/tagicon-default.png?t=N7T8https://github.com/EpicGames/UnrealEngine/releases/tag

若报错:

 个人认为是因执行Setup.sh脚本未赋予root权限导致依赖未安装完整,所以再次执行:

sudo ./Setup.sh
  1. // @file : CubemapUnwrapUtils.cpp
  2. Use
  3. RHICmdList.GetBoundVertexShader() instead of GetVertexShader()
  4. RHICmdList.GetBoundPixelShader() instead of GetPixelShader()
  5. Instead of the given macros, use code as below.
  6. GraphicsPSOInit.BoundShaderState.VertexShaderRHI = VertexShader.GetVertexShader();
  7. GraphicsPSOInit.BoundShaderState.PixelShaderRHI = PixelShader.GetPixelShader();

http://cdn.unrealengine.com/Toolchain_Linux/native-linux-v17_clang-10.0.10centos.tar.gzicon-default.png?t=N7T8http://cdn.unrealengine.com/Toolchain_Linux/native-linux-v17_clang-10.0.10centos.tar.gz

cd your-path/UnrealEngine_4.26/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/
tar -zxvf native-linux-v17_clang-10.0.1-centos7.tar.gz

27.安装Carla0.9.13(添加fisheye sensor模块)

修改Update.sh下载网址为南方科技大学镜像站的网址:

  1. #CONTENT_LINK=http://carla-assets.s3.amazonaws.com/${CONTENT_ID}.tar.gz
  2. CONTENT_LINK=https://mirrors.sustech.edu.cn/carla/carla_content/${CONTENT_ID}.tar.gz
  1. // @file : test_streaming.cpp
  2. // Line 58
  3. carla::streaming::low_level::Server<tcp::Server> srv(io.service, TESTING_PORT);
  4. // Line 63
  5. carla::streaming::low_level::Client<tcp::Client> c;
  6. // Line 93
  7. carla::streaming::low_level::Server<tcp::Server> srv(io.service, TESTING_PORT);
  8. // Line 96
  9. carla::streaming::low_level::Client<tcp::Client> c;
  1. # @file : Package.sh(https://github.com/annaornatskaya/carla/tree/fisheye-sensor)
  2. # copy_if_changed "./Plugins/" "${DESTINATION}/Plugins/"
  3. copy_if_changed "./Unreal/CarlaUE4/Content/Carla/HDMaps/*.pcd" "${DESTINATION}/HDMaps/"
  4. copy_if_changed "./Unreal/CarlaUE4/Content/Carla/HDMaps/Readme.md" "${DESTINATION}/HDMaps/README"
  5. # NOTE: Modified by M0rtzz
  6. if [ -d "./Plugins/" ] ; then
  7. copy_if_changed "./Plugins/" "${DESTINATION}/Plugins/"
  8. fi

  P.S:

推荐一些linux办公常用的软件(linux版,不包括wine环境下,全部下载deb格式的安装包,系统架构可通过命令uname -a查看):

百度网盘 客户端下载

向日葵远程控制app官方下载 - 贝锐向日葵官网

QQ Linux版-新不止步·乐不设限

下载中心-腾讯会议

WPS Office 2019 for Linux-支持多版本下载_WPS官方网站

搜狗输入法-首页(下载安装包后,官方会跳转至安装教程,严格按照步骤执行)

Documentation for Visual Studio Code(推荐打开Settings Sync,换电脑时设置可以同步)

195197efec704c98ba8f61ecc4c8370a.png

bd3b7b33a2744c5cb67011223648eabf.png

 可以水平和垂直分割的bash终端:

sudo apt-get install terminator

74c734b7ca9e4cc5a68246b4f8a73ee3.png

trash命令:

sudo apt-get install trash-cli

tree命令:

sudo apt-get install tree

5434b41e73244f8f941b795586faaea2.png

c344c03378a74cdca9e9585f3c3c14d8.png

查看系统信息:

sudo apt-get install neofetch

e86107d0003945a98d5335abf87680b4.png

rar文件解压工具:

sudo apt-get install unrar

 解决不能观看MP4文件:

sudo apt-get update
sudo apt-get install libdvdnav4 libdvdread4 gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly libdvd-pkg
sudo apt-get install ubuntu-restricted-extras
sudo dpkg-reconfigure libdvd-pkg

 系统优化:

sudo apt-get update
sudo apt-get install gnome-tweak-tool

火狐浏览器优化:

地址栏输入:

about:config

full-screen-api.warning.timeout 

 设置为0~

full-screen-api.transition-duration.enter

 和

full-screen-api.transition-duration.leave

  都设置为0 0~

browser.search.openintab
browser.urlbar.openintab
browser.tabs.loadBookmarksInTabs

都设置为true~

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/43988
推荐阅读
相关标签
  

闽ICP备14008679号