制作ubuntu18.04 cuda10.2+ROS1的 docker镜像

使用的硬件平台为Xavier NX,系统环境如下图:

搭建docker环境需求跟实际环境一致如下图:
从官网获取cuda10.2版本只有支持x86的,如下网站:
https://developer.nvidia.com/cuda-10.2-download-archive

下面从sdk manager中获取方法的进行从论坛中获取:

https://forums.developer.nvidia.com/t/how-to-install-cuda-10-2-to-jetson-tx2/241479/3

小知识:

  1. docker去掉sudo方法:
bash 复制代码
sudo groupadd docker
sudo usermod -aG docker $USER
sudo systemctl restart docker
newgrp docker
id $USER
  1. docker容器启动时,会执行/root/.bashrc。所以自启动的东西可以在/root/.bashrc中进行添加。
  2. 编译依赖cuda,可设置路径 CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-10.2

1. 下载安装包

现在使用的SDK Manager版本为2.1.0.直接打开软件,看到最老的版本只能到4.6.3,如下图:

如果要使用老的JETPACK,如上图我们要使用4.6的版本。我们可以使用下面命令打开SDK Manager:

bash 复制代码
sdkmanager --archived-versions

打开后可以看到老版本如下图:

然后按照正常SDK Manager下载流程下载JETPACK安装包,如下(只下载不进行烧录,等待下载完成):

2. 下载基础镜像

基础镜像地址:https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-base/tags

可以在网站上下载基础docker镜像,如需求32.6.1版本,那么我们使用docker拉取基础镜像:

bash 复制代码
docker pull nvcr.io/nvidia/l4t-base:r32.6.1

3. 启动容器(运行脚本start_docker.sh,内容如下:)

bash 复制代码
#!/bin/bash

docker run -it \
    --rm \
    -v $(pwd)/:/opt/ws/ \
    -v /home:/home \
    -v /etc/localtime:/etc/localtime:ro \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e DISPLAY=unix$DISPLAY \
    -w /opt/ws/ \
    --hostname tn \
    nvcr.io/nvidia/l4t-base:r32.6.1

4. 安装基本环境

  1. 在docker中基于ubuntu18.04 安装ros
    更新source源
bash 复制代码
apt-get update

安装sudo 和 lsb_release工具

bash 复制代码
apt-get install sudo
apt-get install -y vim
sudo apt-get install -y lsb-core
sudo apt install -y python-pip
sudo apt install -y  python3-pip

向ros源中添加ros源地址,并配置公钥,如果rosdep update执行失败,可以尝试多试几次.

bash 复制代码
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) 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 -y ros-melodic-desktop-full
sudo apt install python3-rosdep
sudo rosdep init
sudo rosdep update
source /opt/ros/melodic/setup.sh

rosdep update后正确的打印如下:

bash 复制代码
root@tn:/opt/ws/work# sudo rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Warning: running 'rosdep update' as root is not recommended.
  You should run 'sudo rosdep fix-permissions' and invoke 'rosdep update' again without sudo.
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Skip end-of-life distro "dashing"
Skip end-of-life distro "eloquent"
Skip end-of-life distro "foxy"
Skip end-of-life distro "galactic"
Skip end-of-life distro "groovy"
Add distro "humble"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Add distro "iron"
Skip end-of-life distro "jade"
Add distro "jazzy"
Skip end-of-life distro "kinetic"
Skip end-of-life distro "lunar"
Skip end-of-life distro "melodic"
Add distro "noetic"
Add distro "rolling"
updated cache in /root/.ros/rosdep/sources.cache
  1. 因为我们工程使用的是python3.6,所以将python软连接到python3.8
bash 复制代码
bashroot@tn:/usr/bin# rm -f python
root@tn:/usr/bin# ln -s python3.6 python
  1. 安装cuda
    通过sdk manager下载下来的deb包来安装cuda。可以参考https://developer.ridgerun.com/wiki/index.php/Installing_CUDA-toolkit_and_VisionWorks_Jetson_TX2/Xavier/Nano
    下面可以解决(#include <NvInfer.h>缺失问题):
bash 复制代码
sudo dpkg -i cuda-repo-l4t-10-2-local_10.2.460-1_arm64.deb
sudo apt-key add /var/cuda-repo-l4t-10-2-local/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda-toolkit-10-2
sudo dpkg -i cuda-repo-cross-aarch64-ubuntu1804-10-2-local_10.2.460-1_all.deb
sudo dpkg -i libcudnn8_8.2.1.32-1+cuda10.2_arm64.deb
sudo dpkg -i libnvinfer8_8.0.1-1+cuda10.2_arm64.deb
sudo dpkg -i libcudnn8-dev_8.2.1.32-1+cuda10.2_arm64.deb
sudo dpkg -i libnvinfer-dev_8.0.1-1+cuda10.2_arm64.deb
  1. 安装opencv 4.5.4
    下载opencv4.5.4和opencv_contrib4.5.4版本,将opencv_contrib4.5.4放置在opencv目录下,可以参考:
    https://developer.ridgerun.com/wiki/index.php/Compiling_OpenCV_from_Source
    配置
bash 复制代码
cmake \
-D WITH_FFMPEG=ON \
-D CMAKE_BUILD_TYPE=Release \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules/ \
-D CUDA_CUDA_LIBRARY=/usr/local/cuda/lib64/stubs/libcuda.so \
-D CUDA_ARCH_BIN=6.1 \
-D CUDA_ARCH_PTX="" \
-D WITH_CUDA=ON \
-D WITH_TBB=ON \
-D BUILD_NEW_PYTHON_SUPPORT=ON \
-D WITH_V4L=ON \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D WITH_CUBLAS=1 \
-D WITH_NVCUVID=ON \
-D BUILD_opencv_cudacodec=ON ..

配置输出部分结果如下:

bash 复制代码
--   Other third-party libraries:
--     Lapack:                      NO
--     Eigen:                       YES (ver 3.3.4)
--     Custom HAL:                  YES (carotene (ver 0.0.1))
--     Protobuf:                    build (3.5.1)
-- 
--   NVIDIA CUDA:                   YES (ver 10.2, CUFFT CUBLAS FAST_MATH)
--     NVIDIA GPU arch:             61
--     NVIDIA PTX archs:
-- 
--   cuDNN:                         YES (ver 8.2.1)
-- 
--   OpenCL:                        YES (no extra features)
--     Include path:                /opt/ws/work/opencv/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
-- 
--   Python 2:
--     Interpreter:                 /usr/bin/python2.7 (ver 2.7.17)
--     Libraries:                   /usr/lib/aarch64-linux-gnu/libpython2.7.so (ver 2.7.17)
--     numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.13.3)
--     install path:                lib/python2.7/dist-packages/cv2/python-2.7
-- 
--   Python 3:
--     Interpreter:                 /usr/bin/python3 (ver 3.6.9)
--     Libraries:                   /usr/lib/aarch64-linux-gnu/libpython3.6m.so (ver 3.6.9)
--     numpy:                       /usr/local/lib/python3.6/dist-packages/numpy/core/include (ver 1.19.5)
--     install path:                lib/python3.6/dist-packages/cv2/python-3.6
-- 
--   Python (for build):            /usr/bin/python2.7
-- 
--   Java:                          
--     ant:                         NO
--     JNI:                         NO
--     Java wrappers:               NO
--     Java tests:                  NO
-- 
--   Install to:                    /usr/local
-- -----------------------------------------------------------------
-- 
-- Configuring done

编译并安装

bash 复制代码
make -j8
make install
  1. 配置docker,并导出镜像文件。
bash 复制代码
docker commit -a "tn" -m "drone in xavier nx ubuntu18.04" clever_varahamihira drone-xavier-nx-ubuntu18.04-v1:r32.6.1
docker save -o drone_melodic_xavier_nx_v1.tar drone-xavier-nx-ubuntu18.04-v1:r32.6.1

8.其他设备进行加载。

bash 复制代码
docker load -i drone_melodic_xavier_nx_v1.tar

编译出现的错误如下:

bash 复制代码
CMake Error at CMakeLists.txt:22 (message):
  Search for 'catkin' in workspace failed (catkin_find_pkg catkin
  /opt/ws/work/drone_melodic/catkin_ws/src): Traceback (most recent call
  last):

    File "/usr/bin/catkin_find_pkg", line 6, in <module>
      from pkg_resources import load_entry_point
    File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3088, in <module>
      @_call_aside
    File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3072, in _call_aside
      f(*args, **kwargs)
    File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3101, in _initialize_master_working_set
      working_set = WorkingSet._build_master()
    File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 574, in _build_master
      ws.require(__requires__)
    File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 892, in require
      needed = self.resolve(parse_requirements(requirements))
    File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 778, in resolve
      raise DistributionNotFound(req, requirers)

  pkg_resources.DistributionNotFound: The 'catkin-pkg==0.5.2' distribution
  was not found and is required by the application

解决办法:

bash 复制代码
pip install catkin-tools

bash 复制代码
/opt/ros/melodic/share/genmsg/cmake/pkg-genmsg.cmake.em:56: error: <class 'UnicodeDecodeError'>: 'ascii' codec can't decode byte 0xe7 in position 38: ordinal not in range(128)
Traceback (most recent call last):
  File "/usr/bin/empy", line 3302, in <module>
    if __name__ == '__main__': main()
  File "/usr/bin/empy", line 3300, in main
    invoke(sys.argv[1:])
  File "/usr/bin/empy", line 3283, in invoke
    interpreter.wrap(interpreter.file, (file, name))
  File "/usr/bin/empy", line 2295, in wrap
    self.fail(e)
  File "/usr/bin/empy", line 2284, in wrap
    callable(*args)
  File "/usr/bin/empy", line 2359, in file
    self.safe(scanner, done, locals)
  File "/usr/bin/empy", line 2401, in safe
    self.parse(scanner, locals)
  File "/usr/bin/empy", line 2421, in parse
    token.run(self, locals)
  File "/usr/bin/empy", line 1425, in run
    interpreter.execute(self.code, locals)
  File "/usr/bin/empy", line 2595, in execute
    _exec(statements, self.globals, locals)
  File "<string>", line 38, in <module>
  File "/opt/ros/melodic/lib/python2.7/dist-packages/genmsg/deps.py", line 45, in find_msg_dependencies_with_type
    spec = genmsg.msg_loader.load_msg_from_file(msg_context, msg_file, full_type_name)
  File "/opt/ros/melodic/lib/python2.7/dist-packages/genmsg/msg_loader.py", line 285, in load_msg_from_file
    text = f.read()
  File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 38: ordinal not in range(128)
CMake Error at /opt/ros/melodic/share/catkin/cmake/safe_execute_process.cmake:11 (message):
  
  execute_process(/opt/ws/work/drone_melodic/catkin_ws/build/catkin_generated/env_cached.sh
  "/usr/bin/python3" "/usr/bin/empy" "--raw-errors" "-F"
  "/opt/ws/work/drone_melodic/catkin_ws/build/iking_msg/cmake/iking_msg-genmsg-context.py"
  "-o"
  "/opt/ws/work/drone_melodic/catkin_ws/build/iking_msg/cmake/iking_msg-genmsg.cmake"
  "/opt/ros/melodic/share/genmsg/cmake/pkg-genmsg.cmake.em") returned error
  code 1
Call Stack (most recent call first):
  /opt/ros/melodic/share/catkin/cmake/em_expand.cmake:25 (safe_execute_process)
  /opt/ros/melodic/share/genmsg/cmake/genmsg-extras.cmake:303 (em_expand)
  iking_msg/CMakeLists.txt:76 (generate_messages)


-- Configuring incomplete, errors occurred!

解决办法:

bash 复制代码
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

bash 复制代码
Traceback (most recent call last):
  File "/opt/ros/melodic/share/gencpp/cmake/../../../lib/gencpp/gen_cpp.py", line 43, in <module>
    import genmsg.template_tools
  File "/opt/ros/melodic/lib/python2.7/dist-packages/genmsg/template_tools.py", line 39, in <module>
    import em
ModuleNotFoundError: No module named 'em'
Traceback (most recent call last):
  File "/opt/ros/melodic/share/gencpp/cmake/../../../lib/gencpp/gen_cpp.py", line 43, in <module>
    import genmsg.template_tools
  File "/opt/ros/melodic/lib/python2.7/dist-packages/genmsg/template_tools.py", line 39, in <module>
    import em
ModuleNotFoundError: No module named 'em'
iking_msg/CMakeFiles/iking_msg_generate_messages_cpp.dir/build.make:125: recipe for target '/opt/ws/work/drone_melodic/catkin_ws/devel/include/iking_msg/iking_fc_rc.h' failed
make[2]: *** [/opt/ws/work/drone_melodic/catkin_ws/devel/include/iking_msg/iking_fc_rc.h] Error 1
make[2]: *** Waiting for unfinished jobs....
iking_msg/CMakeFiles/iking_msg_generate_messages_cpp.dir/build.make:118: recipe for target '/opt/ws/work/drone_melodic/catkin_ws/devel/include/iking_msg/iking_fc_imu.h' failed
make[2]: *** [/opt/ws/work/drone_melodic/catkin_ws/devel/include/iking_msg/iking_fc_imu.h] Error 1
CMakeFiles/Makefile2:3492: recipe for target 'iking_msg/CMakeFiles/iking_msg_generate_messages_cpp.dir/all' failed
make[1]: *** [iking_msg/CMakeFiles/iking_msg_generate_messages_cpp.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

解决办法:

bash 复制代码
pip install empy

bash 复制代码
  File "/opt/ros/melodic/lib/python2.7/dist-packages/genmsg/template_tools.py", line 77, in _generate_from_spec
    interpreter = em.Interpreter(output=ofile, globals=g, options={em.RAW_OPT:True,em.BUFFERED_OPT:True})
AttributeError: module 'em' has no attribute 'RAW_OPT'
    interpreter = em.Interpreter(output=ofile, globals=g, options={em.RAW_OPT:True,em.BUFFERED_OPT:True})
AttributeError: module 'em' has no attribute 'RAW_OPT'
    sys.argv, msg_template_map, srv_template_map)

解决办法:

bash 复制代码
pip uninstall empy
pip install empy==3.3.4
bash 复制代码
-- ==> add_subdirectory(thrid_lib/mavros-1.8.0/mavros_msgs)
-- Could NOT find geographic_msgs (missing: geographic_msgs_DIR)
-- Could not find the required component 'geographic_msgs'. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found.
CMake Error at /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
  Could not find a package configuration file provided by "geographic_msgs"
  with any of the following names:

    geographic_msgsConfig.cmake
    geographic_msgs-config.cmake

  Add the installation prefix of "geographic_msgs" to CMAKE_PREFIX_PATH or
  set "geographic_msgs_DIR" to a directory containing one of the above files.
  If "geographic_msgs" provides a separate development package or SDK, be
  sure it has been installed.
Call Stack (most recent call first):
  thrid_lib/mavros-1.8.0/mavros_msgs/CMakeLists.txt:4 (find_package)

解决办法:

bash 复制代码
sudo apt-get install ros-melodic-geographic-msgs

bash 复制代码
-- Could NOT find libmavconn (missing: libmavconn_DIR)
-- Could not find the required component 'libmavconn'. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found.
CMake Error at /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
  Could not find a package configuration file provided by "libmavconn" with
  any of the following names:

    libmavconnConfig.cmake
    libmavconn-config.cmake

  Add the installation prefix of "libmavconn" to CMAKE_PREFIX_PATH or set
  "libmavconn_DIR" to a directory containing one of the above files.  If
  "libmavconn" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  thrid_lib/mavros-1.8.0/mavros/CMakeLists.txt:7 (find_package)

解决办法:

bash 复制代码
apt-get install LibMAVConn*

bash 复制代码
CMake Error at thrid_lib/mavros-1.8.0/mavros/CMakeLists.txt:42 (find_package):
  By not providing "FindGeographicLib.cmake" in CMAKE_MODULE_PATH this
  project has asked CMake to find a package configuration file provided by
  "GeographicLib", but CMake did not find one.

  Could not find a package configuration file provided by "GeographicLib"
  with any of the following names:

    GeographicLibConfig.cmake
    geographiclib-config.cmake

  Add the installation prefix of "GeographicLib" to CMAKE_PREFIX_PATH or set
  "GeographicLib_DIR" to a directory containing one of the above files.  If
  "GeographicLib" provides a separate development package or SDK, be sure it
  has been installed.


-- Configuring incomplete, errors occurred!

解决办法:

bash 复制代码
sudo apt-get install ros-melodic-geographic-*
sudo apt-get install geographiclib-*                                                                 
sudo apt-get install libgeographic-*
sudo ln -s /usr/share/cmake/geographiclib/FindGeographicLib.cmake /usr/share/cmake-3.10/Modules/

bash 复制代码
-- Found OpenCV: /usr (found suitable version "3.2.0", minimum required is "3") found components:  opencv_core opencv_imgproc opencv_imgcodecs 
-- Found PythonLibs: /usr/lib/aarch64-linux-gnu/libpython3.6m.so (found suitable version "3.6.9", minimum required is "3.6") 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'
CMake Error at thrid_lib/cv_bridge/src/CMakeLists.txt:29 (message):
  Could not determine the NumPy include directory, verify that NumPy was
  installed correctly.


-- Configuring incomplete, errors occurred!
See also "/opt/ws/work/drone_melodic/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/opt/ws/work/drone_melodic/catkin_ws/build/CMakeFiles/CMakeError.log".
Invoking "cmake" failed

解决办法:

bash 复制代码
pip install numpy(报错,解决办法如下)

bash 复制代码
  Traceback (most recent call last):
    File "/tmp/pip-build-g4dikta4/numpy/tools/cythonize.py", line 59, in process_pyx
      from Cython.Compiler.Version import version as cython_version
  ModuleNotFoundError: No module named 'Cython'
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "/tmp/pip-build-g4dikta4/numpy/tools/cythonize.py", line 235, in <module>
      main()
    File "/tmp/pip-build-g4dikta4/numpy/tools/cythonize.py", line 231, in main
      find_process_files(root_dir)
    File "/tmp/pip-build-g4dikta4/numpy/tools/cythonize.py", line 222, in find_process_files
      process(root_dir, fromfile, tofile, function, hash_db)
    File "/tmp/pip-build-g4dikta4/numpy/tools/cythonize.py", line 188, in process
      processor_function(fromfile, tofile)
    File "/tmp/pip-build-g4dikta4/numpy/tools/cythonize.py", line 64, in process_pyx
      raise OSError('Cython needs to be installed in Python as a module')
  OSError: Cython needs to be installed in Python as a module
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-build-g4dikta4/numpy/setup.py", line 508, in <module>
      setup_package()
    File "/tmp/pip-build-g4dikta4/numpy/setup.py", line 488, in setup_package
      generate_cython()
    File "/tmp/pip-build-g4dikta4/numpy/setup.py", line 285, in generate_cython
      raise RuntimeError("Running cythonize failed!")
  RuntimeError: Running cythonize failed!
  
  ----------------------------------------
  Failed building wheel for numpy

解决办法:

bash 复制代码
pip install cython
pip install --upgrade pip setuptools wheel
pip install numpy

bash 复制代码
-- Could NOT find serial (missing: serial_DIR)
-- Could not find the required component 'serial'. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found.
CMake Error at /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
  Could not find a package configuration file provided by "serial" with any
  of the following names:

    serialConfig.cmake
    serial-config.cmake

  Add the installation prefix of "serial" to CMAKE_PREFIX_PATH or set
  "serial_DIR" to a directory containing one of the above files.  If "serial"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  perip_module_app/CMakeLists.txt:7 (find_package)

解决办法:

bash 复制代码
apt-get install ros-melodic-serial

bash 复制代码
-- Found OpenCV: /usr (found version "3.2.0") 
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Checking for module 'gstreamer-1.0'
--   No package 'gstreamer-1.0' found
CMake Error at /usr/share/cmake-3.10/Modules/FindPkgConfig.cmake:419 (message):
  A required package was not found
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindPkgConfig.cmake:597 (_pkg_check_modules_internal)
  vision_guide_land/CMakeLists.txt:15 (pkg_check_modules)


-- Configuring incomplete, errors occurred!

解决办法:

bash 复制代码
sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev

bash 复制代码
-- Checking for module 'gstreamer-rtsp-server-1.0'
--   No package 'gstreamer-rtsp-server-1.0' found
CMake Error at /usr/share/cmake-3.10/Modules/FindPkgConfig.cmake:419 (message):
  A required package was not found
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindPkgConfig.cmake:597 (_pkg_check_modules_internal)
  vision_guide_land/CMakeLists.txt:17 (pkg_check_modules)


-- Configuring incomplete, errors occurred!

解决办法:

bash 复制代码
sudo apt-get install libgstrtspserver-1.0-dev gstreamer1.0-rtsp

bash 复制代码
/opt/ws/work/drone_melodic/catkin_ws/src/vision_guide_land/include/tensorrt_yolo/yololayer.h:6:10: fatal error: NvInfer.h: No such file or directory
 #include <NvInfer.h>
          ^~~~~~~~~~~
compilation terminated.
CMake Error at tensorrt_yolov5_generated_yololayer.cu.o.cmake:219 (message):
  Error generating
  /opt/ws/work/drone_melodic/catkin_ws/build/vision_guide_land/CMakeFiles/tensorrt_yolov5.dir/src/tensorrt_yolo/./tensorrt_yolov5_generated_yololayer.cu.o

解决办法:

参考 "5. 安装cuda" 部分。


bash 复制代码
/opt/ws/work/drone_melodic/catkin_ws/src/vision_guide_land/src/tensorrt_yolo/calibrator.cpp:4:10: fatal error: opencv2/dnn/dnn.hpp: No such file or directory
 #include <opencv2/dnn/dnn.hpp>

解决办法:

参考 "6. 安装opencv"


bash 复制代码
e package with the same name or change your environment so that it can be found.
CMake Error at /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
  Could not find a package configuration file provided by "mavros_msgs" with
  any of the following names:

    mavros_msgsConfig.cmake
    mavros_msgs-config.cmake

  Add the installation prefix of "mavros_msgs" to CMAKE_PREFIX_PATH or set
  "mavros_msgs_DIR" to a directory containing one of the above files.  If
  "mavros_msgs" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  vision_guide_land/CMakeLists.txt:19 (find_package)

解决办法:

bash 复制代码
apt-get install ros-melodic-mavros-msgs

bash 复制代码
/usr/bin/ld: cannot find -lglog
collect2: error: ld returned 1 exit status
vision_guide_land/CMakeFiles/tensorrt_yolov5.dir/build.make:268: recipe for target '/opt/ws/work/drone_melodic/catkin_ws/devel/lib/libtensorrt_yolov5.so' failed
make[2]: *** [/opt/ws/work/drone_melodic/catkin_ws/devel/lib/libtensorrt_yolov5.so] Error 1
CMakeFiles/Makefile2:1378: recipe for target 'vision_guide_land/CMakeFiles/tensorrt_yolov5.dir/all' failed
make[1]: *** [vision_guide_land/CMakeFiles/tensorrt_yolov5.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make install -j8 -l8" failed

解决办法:

bash 复制代码
sudo apt-get install libgoogle-glog-dev

bash 复制代码
/usr/bin/ld: warning: libopencv_imgcodecs.so.3.2, needed by /opt/ros/melodic/lib/libcv_bridge.so, may conflict with libopencv_imgcodecs.so.4.5
/usr/bin/ld: warning: libopencv_imgproc.so.3.2, needed by /opt/ros/melodic/lib/libcv_bridge.so, may conflict with libopencv_imgproc.so.4.5
/usr/bin/ld: warning: libnvdla_compiler.so, needed by /usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libnvmedia.so, needed by /usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so, not found (try using -rpath or -rpath-link)
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaTensorDestroy'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaDlaGetMaxOutstandingTasks'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaTensorEglStreamConsumerDestroy'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaTensorEglStreamConsumerAcquireMetaData'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaEglStreamProducerGetTensor'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaDlaDataUnregister'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaDlaGetOutputTensorDescriptor'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `nvdla::destroyNetwork(nvdla::INetwork*)'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `nvdla::createWisdom()'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaTensorGetMetaData'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaDlaRemoveLoadable'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaEglStreamProducerPostTensor'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaDlaAppendLoadable'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaTensorGetStatus'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaDlaDataRegister'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaDlaLoadableCreate'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `nvdla::destroyWisdom(nvdla::IWisdom*)'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaDlaGetInputTensorDescriptor'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaTensorEglStreamProducerCreate'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaDeviceDestroy'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaTensorCreate'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaTensorEglStreamProducerDestroy'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaTensorEglStreamConsumerCreate'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaDlaInit'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaTensorLock'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaDlaGetNumOfInputTensors'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `nvdla::createNetwork()'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaDlaSubmit'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaEglStreamConsumerAcquireTensor'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaDlaLoadLoadable'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaDlaCreate'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaEglStreamConsumerReleaseTensor'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaDlaGetNumEngines'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaDlaDestroy'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaTensorEglStreamProducerPostMetaData'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaDeviceCreate'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaDlaGetNumOfOutputTensors'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaDlaLoadableDestroy'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaDlaSetCurrentLoadable'
/usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to `NvMediaTensorUnlock'
collect2: error: ld returned 1 exit status
vision_guide_land/CMakeFiles/vision_land_node.dir/build.make:336: recipe for target '/opt/ws/work/drone_melodic/catkin_ws/devel/lib/vision_guide_land/vision_land_node' failed
make[2]: *** [/opt/ws/work/drone_melodic/catkin_ws/devel/lib/vision_guide_land/vision_land_node] Error 1
CMakeFiles/Makefile2:477: recipe for target 'vision_guide_land/CMakeFiles/vision_land_node.dir/all' failed
make[1]: *** [vision_guide_land/CMakeFiles/vision_land_node.dir/all] Error 2
Makefile:140: recipe for target 'all' failed

解决办法:

这是缺少GPU底层驱动导致,可以将宿主机(Xavier nx)上的/usr/lib/aarch64-linux-gnu/tegra/ 目录,拷贝至docker响应目录即可,也可以使用挂载的方式。

相关推荐
A ?Charis1 小时前
Gitlab-runner running on Kubernetes - hostAliases
容器·kubernetes·gitlab
城南vision1 小时前
Docker学习—Docker核心概念总结
java·学习·docker
wclass-zhengge1 小时前
Docker篇(Docker Compose)
运维·docker·容器
北漂IT民工_程序员_ZG2 小时前
k8s集群安装(minikube)
云原生·容器·kubernetes
梦魇梦狸º5 小时前
腾讯轻量云服务器docker拉取不到镜像的问题:拉取超时
docker·容器·github
鬼才血脉5 小时前
docker+mysql配置
mysql·adb·docker
詹姆斯爱研究Java5 小时前
Docker 的基本概念和优势
docker
南猿北者7 小时前
docker镜像仓库常用命令
运维·docker·容器
杨浦老苏7 小时前
Docker可视化管理面板DPanel的安装
运维·docker·群晖
2301_806131368 小时前
Kubernetes的基本构建块和最小可调度单元pod-0
云原生·容器·kubernetes