A story of an amateur programmer participating in a contest using Autoware.(Part 1: Building the Autoware environment)


To begin with.

I have nothing to do with programming at work, but I became interested in AI a few years ago and started studying it on my own.
The commands, reference links, etc. may not be applicable in the latest situation.
This is a summary article of what I learned very much from just building an environment for an amateur.

Part 1: Building the Autoware environment 
Part 2: Summary of ROS information
Part 3: Try using Autoware and the LGSVL simulator

0. Why join the contest?

The concept of "software first" and "connected" is about to change the way we manufacture things. I am rarely involved in software in my daily work, but I felt that this was not good enough, so about years ago, I started studying programming, including AI, with a group of volunteers from within the company, separately from my work. I've been studying AI and other programming in addition to my work for about few years now.

1. Installing Ubuntu

Ubuntu won't start.(PC will not boot.)

At the time, I had no idea what Ubuntu was. At that time, I had no idea what Ubuntu was. It seems that the NVIDIA GPU is incompatible with the standard Ubuntu graphics driver, so it won't boot properly.

link

Disable nouveau

1. Go into the BIOS menu and set Secure Boot to Disabled.

2. Hover the cursor overInstall Ubuntu  Configuring Push e to Start Options.

3.You can disable nouveau by rewriting quiet splash --- to quiet splash nomodeset ---.

unable to nvidia-smi (Installing GPU driver)

link

Install_GPU_Driver
ubuntu-drivers devices
sudo apt update
sudo apt install nvidia-driver-***

If it doesn't work, click here.
Find and install the driver in NVIDIA
If you can't find it, beta version

Install_GPU_Driver
sudo bash NVIDIA-Linux-x86_64-440.36.run

2. What you need to install

List of nvidia-drivers and CUDA Toolkit for GPUs is here
Make sure you install the corresponding one!

Install CUDA Toolkit 10.0

The first step is to install CUDA. In this case, Autoware recommends CUDA10, so we will install that.

CUDA_Toolkit_10.0
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /"
sudo apt-get update
sudo apt-get -y install cuda-10.0
# add PATH to bashrc
echo -e "\n## CUDA and cuDNN paths"  >> ~/.bashrc
echo 'export PATH=/usr/local/cuda-10.0/bin:${PATH}' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64:${LD_LIBRARY_PATH}' >> ~/.bashrc
source ~/.bashrc
# reboot PC
sudo reboot

Install docker

Install Docker Engine on Ubuntu

Install_Docker_Engine_on_Ubuntu
sudo apt-get update

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
# Allowing ordinary users to use docker commands
sudo usermod -aG docker $USER
reboot

Install nvidia-docker and nvidia-docker2

This seems to be the latest.NVIDIA Docker って今どうなってるの? (20.09 版)
Install it by referring to this page. NVIDIA-DOCKER2の始め方

Install_nvidia-docker2
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
  sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/ubuntu16.04/amd64/nvidia-docker.list | \
  sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update

sudo apt-get install nvidia-docker2
sudo pkill -SIGHUP dockerd
operation_check-nvidia-docker2
sudo docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi

Note that if the confirmation command works and does not pull the image, it did not go well.

operation_check-nvidia-docker
docker run --runtime nvidia nvidia/cuda:10.0-base nvidia-smi

Installing ROS  <- (Not required if you use docker)

RThe supported version of ROS depends on the OS version, and melodic will be installed on Ubuntu 18.04.
Click here

ROS_melodic_install
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 ros-melodic-desktop-full
# Add to bashrc so that ROS environment files will be loaded on next boot.
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc

# Install dependencies
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
sudo apt install python-rosdep
sudo rosdep init
rosdep update

3. Building Autoware

There are two types of Autoware: Autoware-docker, which is launched by docker, and the method of building directly on the local PC.
Autoware-docker is recommended.
Even if the ROS environment or Autoware is broken and stops working, docker can quickly restore it.

Autoware-docker

First, find out the user ID.

Check_user_ID
id

Autoware-docker build. In this example, we will build v1.13.0. In this case, we will build v1.13.0, so we will specify the version.

Autoware-docker_build
git clone https://github.com/Autoware-AI/docker.git
cd docker/generic
# uid=1000
./run.sh -t 1.13.0
# uid!=1000
./run.sh -s -t 1.13.0

【Add】

Make sure that the image remains even after exiting from docker.
If you don't do this, the image will not remain after you exit from docker, and you will have to start building the package again.
To avoid this, it is easy to change this last part Autoware-docker/run.sh. To avoid this, it is easy to change this last part, although it will cause the image to be created every time you ./run.sh.

run.sh

*****

docker run \
    -it\          #<=remove command "--rm" 
    $VOLUMES \
    --env="XAUTHORITY=${XAUTH}" \
    --env="DISPLAY=${DISPLAY}" \
    --env="USER_ID=$USER_ID" \
    --privileged \
    --net=host \
    $RUNTIME \
    $IMAGE

To build from source

Autoware-docker Source Build
In my environment, the part where Eigen is built did not work, so I changed it.

Autoware_AI_Source_Build
# Install dependencies
sudo apt update
sudo apt install -y python-catkin-pkg python-rosdep ros-$ROS_DISTRO-catkin
sudo apt install -y python3-pip python3-colcon-common-extensions python3-setuptools python3-vcstool
pip3 install -U setuptools
# Install Eigen
cd && wget http://bitbucket.org/eigen/eigen/get/3.3.7.tar.gz 
mkdir eigen && tar --strip-components=1 -xzvf 3.3.7.tar.gz -C eigen
cd eigen && mkdir build && cd build && cmake .. && make
sudo make install #<=Add sudo
Autoware_AI_Source_Build
mkdir -p autoware.ai/src
cd autoware.ai

# Specify the version to build v1.13.0
wget -O autoware.ai.repos "https://gitlab.com/autowarefoundation/autoware.ai/autoware/raw/1.13.0/autoware.ai.repos?inline=false"
vcs import src < autoware.ai.repos
sudo rosdep init
rosdep update
rosdep install -y --from-paths src --ignore-src --rosdistro melodic
source /opt/ros/melodic/setup.bash

# WITH CUDA support
AUTOWARE_COMPILE_WITH_CUDA=1 colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release

# WITHOUT CUDA Support
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release

If the Autoware Runtime Manager starts, the build is successful.

Autoware_runtime_manager
# Loading Autoware environment
source ~/Autoware/install/local_setup.bash
# Launch runtime_manager
roslaunch runtime_manager runtime_manager.launch

Thank you for your hard work. No matter how well it goes, it will take a whole day to get this far. (The first time I did it, it took me about four days through trial and error.
So far, I've finally finished setting up the environment to run Autoware. I would like to write again about how to learn ROS and how to use Autoware.

4. Links

自動運転AIチャレンジ
ubuntu18.04にnvidiaドライバを入れるの苦労した
エヌビディア製品用ドライバ
エヌビディア製品用ドライバのベータ版
Deep Learning 環境の構築
Autoware.AI Source Build
Ubuntu 18.04へのCUDAインストール方法
NVIDIA CUDA Installation Guide for Linux
Install Docker Engine on Ubuntu
NVIDIA Docker って今どうなってるの? (19.11版)
NVIDIA Docker って今どうなってるの? (20.09 版)
NVIDIA-DOCKER2の始め方
Ubuntu install of ROS Melodic
id - ユーザIDやグループIDを表示する
Autoware-docker build
Autoware-docker Source Build
Ubuntu18.04にAutoware.AIをインストール
Ubuntuの18.04 - NVIDIAドライバをインストールする方法
NVIDIA CUDA Toolkit Release Notes