Arm64v8架构下Autopolit环境Docker镜像制作

硬件环境

NVIDIA Jetson AGX Xavier Developer Kit (32GB)

  • GPU 搭载 Tensor Core 的 512 核 Volta GPU
  • CPU 8 核 ARM v8.2 64 位 CPU、8 MB L2 + 4 MB L3
  • 内存 32 GB 256 位 LPDDR4x | 137 GB/秒
  • 存储 32 GB eMMC 5.1
  • PCIe X16 X8 PCIe Gen4/x8 SLVS-EC
  • RJ45 千兆以太网
  • USB-C 2 个 USB 3.1 接口、DP 接口(可选)、PD 接口(可选) 可通过同一端口支持封闭系统调试和烧写
  • 摄像头接口 (16 个)CSI-2 通道
  • M.2 Key M NVMe
  • M.2 Key E PCIe x1 + USB 2.0 + UART (for Wi-Fi/LTE) / I2S + DMIC + GPIOs
  • 40 针接头 UART + SPI + CAN + I2 C + I2 S + DMIC + GPIOs
  • 高清音频接头 高清音频
  • eSTATp + USB 3.0 Type A 借助 PCIe x1 桥接器的 SATA 接口 + USB 3.0(PD + 适用于 2.5 英寸 SATA 接口的数据)
  • HDMI Type A HDMI 2.0
  • µSD/UFS 卡座 SD/UFS

软件环境

  • jetson4.4
  • vnc & xface
  • ros
  • osqp & qpOASES
  • cuda10.2
  • pcan8.10
  • tensorrt7.1
  • opencv4.1

Dockerfile

FROM arm64v8/ubuntu:18.04

COPY file/clean-layer.sh /usr/bin/clean-layer.sh

RUN chmod +x /usr/bin/clean-layer.sh \
    && /usr/bin/clean-layer.sh \
    && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && echo "Asia/Shanghai" > /etc/timezone

#COPY file
ADD file/1_sys_config.sh /tmp/
RUN apt-get update \
    && apt-get install -y vim busybox net-tools iputils-ping iproute2 gpg apt-utils locales \
    && sh /tmp/1_sys_config.sh \
    && /usr/bin/clean-layer.sh

#Install VNC&XFCE
RUN gpg --keyserver keyserver.ubuntu.com --recv F42ED6FBAB17C888 \
    && gpg --export --armor F42ED6FBAB17C888 | apt-key add - \
    && sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \
    && locale-gen \
    && dpkg-reconfigure --frontend=noninteractive locales \
    && update-locale LANG=en_US.UTF-8 \
    && apt-get update \
    && apt-get install -y xfce4 xfce4-terminal tigervnc-standalone-server \
    && bash -c "yes | apt-get install -y sudo" \
    && /usr/bin/clean-layer.sh

RUN echo "user" | adduser autopolit && \
    echo "autopolit ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
    usermod -aG dialout autopolit
# Install ros
ADD file/ros.key /tmp/ros.key
RUN apt-key add /tmp/ros.key \
    && apt-get update \
    && apt install -y ros-melodic-desktop-full \
       ros-melodic-cv-bridge ros-melodic-abseil-cpp \
       python-rosdep libgoogle-glog-dev libpcap-dev \
       python3-qtpy python3-pip \
       libopenblas-dev liblapacke-dev \
       cmake libavcodec-dev libavformat-dev libavutil-dev \
       libeigen3-dev libglew-dev libgtk2.0-dev libgtk-3-dev \
       libjpeg-dev libpng-dev libpostproc-dev libswscale-dev \
       libtbb-dev libtiff5-dev libv4l-dev libxvidcore-dev \
       libx264-dev qt5-default \
       zlib1g-dev libgl1 libglvnd-dev pkg-config \
       libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
       python-simplejson python-pip exfat-utils \
    && /usr/bin/clean-layer.sh

RUN sudo -H pip3 install jetson-stats rosdep \
    && sudo pip install google protobuf \
    && ln -s /usr/bin/vtk6 /usr/bin/vtk \
    && ln -s /usr/lib/aarch64-linux-gnu/python2.7/site-packages/vtk/libvtkRenderingPythonTkWidgets.aarch64-linux-gnu.so /usr/lib/aarch64-linux-gnu/libvtkRenderingPythonTkWidgets.so

#安装中文字体
RUN apt-get update \
    && apt-get install -y fonts-droid-fallback ttf-wqy-zenhei ttf-wqy-microhei fonts-arphic-ukai fonts-arphic-uming \
    && /usr/bin/clean-layer.sh

# Install osqp & qpOASES
ADD tools/osqp.zip /tmp/osqp.zip
ADD tools/qpOASES-3.2.1.zip  /tmp/qpOASES.zip
RUN cd /tmp \
    && unzip osqp.zip \
    && unzip qpOASES.zip \
    && cd /tmp/osqp \
    && bash install.sh \
    && cd /tmp/qpOASES-3.2.1 \
    && mkdir build \
    && cd build \
    && cmake .. \
    && make install \
    && cd / \
    && rm -rf /tmp/*
# Install cuda
ADD tools/cuda /tmp/
RUN dpkg -i /tmp/*.deb \
    && apt-key add /var/cuda-repo-10-2-local-10.2.89/7fa2af80.pub \
    && apt-get update \
    && apt-get install cuda-toolkit-10.2 -y \
    && echo "export PATH=/usr/local/cuda/bin:$PATH" >> /home/autopolit/.bashrc \
    && echo "export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH" >> /home/autopolit/.bashrc \
    && echo "export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH" >> /home/autopolit/.bashrc \
    && echo "source /opt/ros/melodic/setup.bash" >> /home/autopolit/.bashrc \
    && rm -rf /tmp/* \
    && /usr/bin/clean-layer.sh

# Install pcan
ADD file/linux-headers-4.9.140-tegra /usr/src/linux-headers-4.9.140-tegra/
ADD file/pcanlib/etc/modules.conf.local /etc/
ADD file/pcanlib/lib/modules/4.9.140-tegra /lib/modules/4.9.140-tegra/
ADD file/pcanlib/usr/include /usr/include/
ADD file/pcanlib/usr/lib /usr/lib/
ADD file/pcanlib/usr/local/bin /usr/local/bin/
ADD tools/peak-linux-driver-8.10.2.tar.gz /tmp/
ADD file/tegra /usr/lib/aarch64-linux-gnu/tegra/
RUN echo "/usr/lib/aarch64-linux-gnu/tegra" >> /etc/ld.so.conf.d/aarch64-linux-gnu.conf \
    && ldconfig
RUN apt-get update \
    && apt-get install -y kmod libpopt-dev \
    && cd /tmp/peak-linux-driver-8.10.2 \
    && make all NET=NO PCI=NO ISA=NO DNG=NO PCC=NO \
    && modprobe pcan \
    && rm -rf /tmp/* \
    && /usr/bin/clean-layer.sh

#Install  opencv
ADD tools/build_opencv /tmp/
RUN cd /tmp \
    && ./buildOpenCV.sh \
    && rm -rf /tmp/*

# lib
ADD tools/libnvinfer-dev_7.1.3-1+cuda10.2_arm64.deb /tmp/
ADD tools/libnvinfer7_7.1.3-1+cuda10.2_arm64.deb /tmp/
RUN dpkg -i /tmp/*.deb \
    && rm -rf /tmp/*

#Install tensorrt
ADD tools/tensorrt /tmp
RUN dpkg -i /tmp/libnv* \
    && dpkg -i /tmp/tensorrt_7.1.3.0-1+cuda10.2_arm64.deb \
    && rm -rf /tmp/*


#添加VNC文件,设置环境变量
ADD file/xstartup /autocar-code/xstartup
ADD file/passwd /autocar-code/passwd
ADD file/.Xauthority /autocar-code/.Xauthority
RUN mkdir /home/autopolit/.vnc \
    && cp /autocar-code/passwd /home/autopolit/.vnc/ \
    && cp /autocar-code/xstartup /home/autopolit/.vnc/ \
    && cp /autocar-code/.Xauthority /home/autopolit/ \
    && chown -R autopolit:autopolit /home/autopolit \
    && chown -R autopolit:autopolit /autocar-code