Skip to content

Instantly share code, notes, and snippets.

@atinfinity
Last active August 3, 2023 02:24
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save atinfinity/d8d1f18b2dd6be5c4c45edc59544a395 to your computer and use it in GitHub Desktop.
Save atinfinity/d8d1f18b2dd6be5c4c45edc59544a395 to your computer and use it in GitHub Desktop.
Autoware Auto(w/o ADE) on Docker
FROM nvidia/cuda:11.1-cudnn8-devel-ubuntu20.04
ENV NVIDIA_VISIBLE_DEVICES ${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics
# add new sudo user
ENV USERNAME autoware
ENV HOME /home/$USERNAME
RUN useradd -m $USERNAME && \
echo "$USERNAME:$USERNAME" | chpasswd && \
usermod --shell /bin/bash $USERNAME && \
usermod -aG sudo $USERNAME && \
mkdir /etc/sudoers.d && \
echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$USERNAME && \
chmod 0440 /etc/sudoers.d/$USERNAME && \
# Replace 1000 with your user/group id
usermod --uid 1000 $USERNAME && \
groupmod --gid 1000 $USERNAME
# install package
RUN echo "Acquire::GzipIndexes \"false\"; Acquire::CompressionTypes::Order:: \"gz\";" > /etc/apt/apt.conf.d/docker-gzip-indexes
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
sudo \
less \
emacs \
apt-utils \
tzdata \
git \
tmux \
bash-completion \
command-not-found \
software-properties-common \
curl \
gnupg2 \
lsb-release \
keyboard-configuration \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# install Git LFS
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash && \
apt-get install git-lfs && \
git lfs install && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# install ROS2 foxy
RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null
RUN apt-get update && apt-get install -y --no-install-recommends \
ros-foxy-ros-base \
ros-foxy-rmw-cyclonedds-cpp \
python3-argcomplete \
python3-colcon-common-extensions \
python3-pip \
python3-vcstool \
python3-rosdep \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN rosdep init
USER $USERNAME
WORKDIR /home/$USERNAME
RUN rosdep update
SHELL ["/bin/bash", "-c"]
# install Autoware Auto
RUN source /opt/ros/foxy/setup.bash && \
git lfs clone https://gitlab.com/autowarefoundation/autoware.auto/AutowareAuto.git -b 1.0.0 && \
cd AutowareAuto && \
sed -i -e 's/ fetchexclude = \*.pcd//' .lfsconfig && \
git lfs pull && \
sudo apt-get update && \
vcs import < autoware.auto.$ROS_DISTRO.repos && \
rosdep install -y -i --from-paths src && \
sudo mkdir /opt/AutowareAuto && \
sudo chmod 777 /opt/AutowareAuto && \
colcon build --install-base /opt/AutowareAuto --cmake-args -DCMAKE_BUILD_TYPE=Release && \
sudo apt-get clean && \
sudo rm -rf /var/lib/apt/lists/*
RUN echo "source /opt/ros/foxy/setup.bash" >> ~/.bashrc && \
echo "source /opt/AutowareAuto/setup.bash" >> ~/.bashrc && \
echo "source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash" >> ~/.bashrc && \
echo "export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp" >> ~/.bashrc && \
source ~/.bashrc
#!/bin/sh
XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
touch $XAUTH
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
docker run --runtime=nvidia --privileged --rm -it \
--volume=$XSOCK:$XSOCK:rw \
--volume=$XAUTH:$XAUTH:rw \
--volume=$HOME:$HOME \
--shm-size=1gb \
--env="XAUTHORITY=${XAUTH}" \
--env="DISPLAY=${DISPLAY}" \
--env=TERM=xterm-256color \
--env=QT_X11_NO_MITSHM=1 \
--net=host \
autoware.auto:1.0.0 \
bash
@atinfinity
Copy link
Author

atinfinity commented May 27, 2021

Create Docker image

docker build -t autoware.auto:1.0.0 .

I refered to the following document to make this Dockerfile.

Launch Docker Container

./launch_container.sh

Demo(localization_rosbag)

Download rosbag file

curl https://autoware-auto.s3.us-east-2.amazonaws.com/rosbag2/rosbag2-astuff-1-lidar-only.tar.gz | tar xz

Launch Demo

ros2 launch autoware_demos localization_rosbag.launch.py

Screenshot from 2021-05-27 12-56-21

Please refer to https://autowarefoundation.gitlab.io/autoware.auto/AutowareAuto/rosbag-localization-howto.html.

@NovoG93
Copy link

NovoG93 commented Jun 20, 2022

Due to the current nvidia GPG problems (see here), I needed to add the following lines to be able to build:

    ENV DEBIAN_FRONTEND noninteractive
+  RUN apt-key del 7fa2af80
+  RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub
+  RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu2004/x86_64/7fa2af80.pub
    RUN apt-get update && apt-get install -y --no-install-recommends \

@atinfinity
Copy link
Author

@NovoG93 NVIDIA says that the following comment.

The container images for 11.0+ should all be live at this point.

https://forums.developer.nvidia.com/t/updating-the-cuda-linux-gpg-repository-key/212897/23

And, my Dockerfile uses nvidia/cuda:11.1-cudnn8-devel-ubuntu20.04.
So, I don't think this problem will occur.

@NovoG93
Copy link

NovoG93 commented Jun 20, 2022

@atinfinity If I don't add the lines as described above I receive the following error:

georg@georg-asus:~/git/ROS2/Autoware/gist$ docker build -t autoware.auto:1.0.0 .
Sending build context to Docker daemon  6.656kB
Step 1/20 : FROM nvidia/cuda:11.1-cudnn8-devel-ubuntu20.04
 ---> 4c81d489aa36
Step 2/20 : ENV NVIDIA_VISIBLE_DEVICES ${NVIDIA_VISIBLE_DEVICES:-all}
 ---> Running in a98c32fa34a1
Removing intermediate container a98c32fa34a1
 ---> 7e8f46faa993
Step 3/20 : ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics
 ---> Running in 15fd847e1293
Removing intermediate container 15fd847e1293
 ---> 128c370dab31
Step 4/20 : ENV USERNAME autoware
 ---> Running in ea0245b6eb7f
Removing intermediate container ea0245b6eb7f
 ---> ebab8159389e
Step 5/20 : ENV HOME /home/$USERNAME
 ---> Running in c724d9e477d5
Removing intermediate container c724d9e477d5
 ---> 74a74bdab03b
Step 6/20 : RUN useradd -m $USERNAME &&         echo "$USERNAME:$USERNAME" | chpasswd &&         usermod --shell /bin/bash $USERNAME &&         usermod -aG sudo $USERNAME &&         mkdir /etc/sudoers.d &&         echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$USERNAME &&         chmod 0440 /etc/sudoers.d/$USERNAME &&         usermod  --uid 1000 $USERNAME &&         groupmod --gid 1000 $USERNAME
 ---> Running in acf707d8c0bc
usermod: no changes
Removing intermediate container acf707d8c0bc
 ---> f55f66952624
Step 7/20 : RUN echo "Acquire::GzipIndexes \"false\"; Acquire::CompressionTypes::Order:: \"gz\";" > /etc/apt/apt.conf.d/docker-gzip-indexes
 ---> Running in 615b2723146c
Removing intermediate container 615b2723146c
 ---> c68364abe594
Step 8/20 : ENV DEBIAN_FRONTEND noninteractive
 ---> Running in 664a262d6b25
Removing intermediate container 664a262d6b25
 ---> 4ff17b9e2bb8
Step 9/20 : RUN apt-get update && apt-get install -y --no-install-recommends         build-essential         sudo         less         emacs         apt-utils         tzdata         git         tmux         bash-completion         command-not-found         software-properties-common         curl         gnupg2         lsb-release         keyboard-configuration         &&     apt-get clean &&     rm -rf /var/lib/apt/lists/*
 ---> Running in c66a6ccd0b7f
Get:1 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:2 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64  InRelease [1581 B]
Err:2 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64  InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY A4B469963BF863CC
Get:3 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages [1275 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages [11.3 MB]
Get:8 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [1324 kB]
Ign:9 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu2004/x86_64  InRelease
Get:10 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu2004/x86_64  Release [564 B]
Get:11 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu2004/x86_64  Release.gpg [833 B]
Get:12 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu2004/x86_64  Packages [2445 B]
Get:13 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [177 kB]
Get:14 http://archive.ubuntu.com/ubuntu focal/restricted amd64 Packages [33.4 kB]
Get:15 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [2415 kB]
Get:16 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [27.5 kB]
Get:17 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [1974 kB]
Get:18 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [881 kB]
Get:19 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [30.3 kB]
Get:20 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [1161 kB]
Get:21 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [1404 kB]
Get:22 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [27.1 kB]
Get:23 http://archive.ubuntu.com/ubuntu focal-backports/main amd64 Packages [54.2 kB]
Reading package lists...
W: GPG error: https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64  InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY A4B469963BF863CC
E: The repository 'https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64  InRelease' is not signed.
The command '/bin/sh -c apt-get update && apt-get install -y --no-install-recommends         build-essential         sudo         less         emacs         apt-utils         tzdata         git         tmux         bash-completion         command-not-found         software-properties-common         curl         gnupg2         lsb-release         keyboard-configuration         &&     apt-get clean &&     rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100
georg@georg-asus:~/git/ROS2/Autoware/gist$ date
Mon 20 Jun 2022 06:36:42 PM CEST

Also colcon build --install-base /opt/AutowareAuto --cmake-args -DCMAKE_BUILD_TYPE=Release fails for me (after fixing the nvidia GPG) with:

Finished <<< spinnaker_camera_nodes [2.08s]
Finished <<< socketcan [20.6s]
Finished <<< xsens_driver [21.0s]
Starting >>> xsens_nodes
Finished <<< velodyne_driver [22.4s]
Finished <<< signal_filters [22.5s]
Finished <<< autoware_auto_msgs [48.9s]
Starting >>> autoware_auto_geometry
Starting >>> motion_testing
Starting >>> had_map_utils
Starting >>> autoware_auto_tf2
Starting >>> vehicle_interface
Starting >>> lidar_integration
Starting >>> off_map_obstacles_filter
Starting >>> trajectory_spoofer
Starting >>> joystick_vehicle_interface
Finished <<< optimization [23.4s]
Starting >>> localization_common
Finished <<< motion_model [25.0s]
Starting >>> kalman_filter
--- stderr: xsens_nodes
In file included from /home/autoware/AutowareAuto/src/drivers/xsens_nodes/src/xsens_imu_node.cpp:17:
/home/autoware/AutowareAuto/src/drivers/xsens_nodes/include/xsens_nodes/xsens_imu_node.hpp:28:10: fatal error: serial_driver/serial_driver_node.hpp: No such file or directory
   28 | #include "serial_driver/serial_driver_node.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/xsens_imu_node.dir/build.make:63: CMakeFiles/xsens_imu_node.dir/src/xsens_imu_node.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:167: CMakeFiles/xsens_imu_node.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
---
Failed   <<< xsens_nodes [5.02s, exited with code 2]

@atinfinity
Copy link
Author

atinfinity commented Jun 20, 2022

@NovoG93 Sorry. I tried to run docker build. As a result, this problem(GPG error) has been reproduced. It seems that NVIDIA's comment was incorrect in forum.

/home/autoware/AutowareAuto/src/drivers/xsens_nodes/include/xsens_nodes/xsens_imu_node.hpp:28:10: fatal error: serial_driver/serial_driver_node.hpp: No such file or directory

This post may be helpful.
https://answers.ros.org/question/389543/autowareauto-100-build-failed-with-xsens_nodes-and-euclidean_cluster/

And, I found that the documentation of Autoware is updated.


This Dockerfile is throwaway code for my study of Autoware.
So, I have no plans to maintain.

@NovoG93
Copy link

NovoG93 commented Jun 20, 2022

Will look into the links and when I find a solution post it here.

This Dockerfile is throwaway code for my study of Autoware.
So, I have no plans to maintain.

Thank you for your help, appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment