LoginSignup
6
4

自動運転AIチャレンジ2023インテグレーション大会環境構築メモ

Last updated at Posted at 2023-07-12

自動運転AIチャレンジ2023インテグレーション大会環境構築メモ

先人の記事をリスペクトしつつ、環境構築時の個人メモを残します。初心者です。わからない言葉のメモも紛れ込んでます。間違ってたり過不足あったり、不備見つけたらコメントいただけるとありがたいです。

参考にさせていただいた記事

記事の内容に沿ってインストールさせていただきました。本当にありがとうございます。もし不都合あれば当記事を削除いたします。

  • @h_bog(H Bog)様(神)の記事

  • 公式ページ

PC環境

  • OS: Ubuntu 22.04 LTS
  • CPU: 13th Gen Intel(R) Core(TM) i7-13700F (16コア)
  • GPU: GeForce RTX 3060 12GB
  • Memory: 32GB
  • Storage: 1.0TB

事前準備

Nvidiaドライバのインストール

Vulkunのインストール

そもそも、Valkanとは?
https://www.dospara.co.jp/5info/cts_str_pc_vulkan.html

Vulkan(ヴァルカン)とは?次世代グラフィックスAPI。OpenGLなどの策定で知られるKhronos Group(クロノスグループ)が発表したグラフィックスAPI「Vulkan(ヴァルカン)」。

  • パッケージリストの更新
$ sudo apt update
  • libvulkan1をインストール
$ sudo apt install libvulkan1

コースの準備

GoogleDriveから最新のAWSIM_AIChallenge_Ubuntu_v2.0.zipをダウンロードし、解凍。パーミッションを確認して、AWSIM.x86_64をダブルクリックで実行。画面が表示されることを確認する。

Dockerのインストール

参考:https://docs.docker.com/engine/install/ubuntu/

dockerがインストールされてないことを確認。(インストールされていたらアンインストール)

$ docker --version
# インストールの下準備
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# 最新のDockerをインストール
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
719385e32844: Pull complete 
Digest: sha256:a13ec89cdf897b3e551bd9f89d499db6ff3a7f44c5b9eb8bca40da20eb4ea1fa
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Hello from Docker!の表示があればOK。

Rockerのインストール

参考: Docker・rocker でGUIとGPUが使えるROS 2 Humbleの環境を作る

sudo apt-get install python3-rockerだけでインストールできたとのことでしたが、私の環境では下準備が必要でした。

sudo apt update && sudo apt install curl gnupg lsb-release
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
sudo apt update
sudo apt-get install python3-rocker

NVIDIA Container Toolkitのインストール

# インストールの下準備
$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
      && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
      && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
            sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
            sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list

# インストール
$ sudo apt-get update
$ sudo apt-get install -y nvidia-container-toolkit
$ sudo nvidia-ctk runtime configure --runtime=docker
$ sudo systemctl restart docker
# インストールできているかをテスト
$ sudo docker run --rm --runtime=nvidia --gpus all nvidia/cuda:11.6.2-base-ubuntu20.04 nvidia-smi
Unable to find image 'nvidia/cuda:11.6.2-base-ubuntu20.04' locally
11.6.2-base-ubuntu20.04: Pulling from nvidia/cuda
56e0351b9876: Pull complete 
0e353182dfa4: Pull complete 
63add13c711b: Pull complete 
1210b79751b0: Pull complete 
eb1e2ff09225: Pull complete 
Digest: sha256:4b0c83c0f2e66dc97b52f28c7acf94c1461bfa746d56a6f63c0fef5035590429
Status: Downloaded newer image for nvidia/cuda:11.6.2-base-ubuntu20.04
Tue Jul 11 14:36:25 2023       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.125.06   Driver Version: 525.125.06   CUDA Version: 12.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  Off  | 00000000:01:00.0  On |                  N/A |
|  0%   52C    P8    16W / 170W |    250MiB / 12288MiB |      3%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
+-----------------------------------------------------------------------------+

git lfsのインストール

そもそもGit LFSとは?

Git LFSとは?Gitは、音声・動画・高画質な画像などの大きなファイルを扱うことは不得意です。Gitリポジトリにそのような大きなファイルを含めると、git clone・git push・git pullの処理に膨大な時間がかかります。Git LFS (Large File Storage以下、LFS) は前述した問題を解決すべく、GitHub・Microsoft・Atlassian、および他のコントリビュータによって開発されているGitの拡張機能です。これにより、大きなファイルをより効率的に扱うことができます。

とのこと。大きなファイルを含める際にはLFSを用いる。

$ curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
$ sudo apt-get install git-lfs

ROS2のインストール

# インストールの下準備
$ sudo apt install software-properties-common
$ sudo add-apt-repository universe
$ sudo apt update && sudo apt install curl -y
$ sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

# インストール
$ sudo apt update
$ sudo apt upgrade
$ sudo apt install ros-humble-desktop

# 環境構築
source /opt/ros/humble/setup.bash

動作確認

# In one terminal, source the setup file and then run a C++ talker:
$ source /opt/ros/humble/setup.bash
$ ros2 run demo_nodes_cpp talker

# In another terminal source the setup file and then run a Python listener:
$ source /opt/ros/humble/setup.bash
$ ros2 run demo_nodes_py listener

AWSIMとAutowareのセットアップ

Dockerイメージの準備・起動 〜 Autowareの準備

1. Dockerイメージを入手

こちらのイメージをtarにまとめたものをダウンロード。

$ docker load < autoware-universe-cuda_v1.tar.gz
permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/load?quiet=0": dial unix /var/run/docker.sock: connect: permission denied

ここでpermission deniedとなりました。どうやら、

dockerコマンドはデフォルトではroot権限なしには叩けないようになっています。

とのことです。

参照: Got permission denied while trying to connect to the Docker daemon socket at 解決方法

$ sudo chmod 666 /var/run/docker.sock
$ docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

permission deniedが表示されず、docker psが動くことで、権限を付与できたことを確認。

再度実行。

$ docker load < autoware-universe-cuda_v1.tar.gz

2. 大会用データのダウンロード

$ git lfs clone https://github.com/AutomotiveAIChallenge/aichallenge2023-sim

3. 大会用dockerイメージのビルド

$ cd ./aichallenge2023-sim/docker
$ bash build.sh

4. 大会用dockerコンテナの起動

$ bash run_container.sh

Dockerコンテナ内でのAWSIM起動

aichallenge2023-sim/docker/aichallenge内に大会用AWSIM実行ファイルを展開(=コースの準備でダウンロードしたファイルをここに配置)。aichallenge2023-sim/docker/aichallenge/AWSIM/AWSIM.x86_64が配置されている状態となる。

新たにターミナルを開いて下記確認。

$ docker image ls
aichallenge-train   latest   d0906e9f90fa   5 minutes ago   14.9GB

確認ができたら以下のコマンドでrockerを起動。

$ cd ./aichallenge2023-sim/docker
$ bash run_container.sh

新たに開いたterminalでdocker container ls で以下のようにdocker が存在していることを確認。

$ docker container ls 
CONTAINER ID   IMAGE          COMMAND       CREATED          STATUS          PORTS     NAMES
9868b7a8775b   5a77f44122e0   "/bin/bash"   26 seconds ago   Up 26 seconds             heuristic_hermann
f2e758768c94   5a77f44122e0   "/bin/bash"   7 minutes ago    Up 7 minutes              clever_mendel

コンテナ内で以下を実行。

$ sudo ip link set multicast on lo
$ source /autoware/install/setup.bash
$ /aichallenge/AWSIM/AWSIM.x86_64

地図データ(pcd, osm)のコピー

地図データはAWSIMの圧縮ファイル内に格納されています。AWSIM_Data/StreamingAssets/kashiwanoha2023_integに配置されているosmファイルとpcdファイルをaichallenge2023-sim/docker/aichallenge/mapfileにコピーして、ファイル構成が以下になるように配置。

aichallenge2023-sim
└ docker
 └ aichallenge
  └ mapfile
   ├ lanelet2_map.osm
   └ pointcloud_map.pcd

公式ページでは.gitkeepが存在していたが、私の環境には存在していません。

Autoware

公式ページ#Autowareを参照。

新たにターミナルを開いて、コンテナに入り、ros2を実行していく。

# コンテナ内に入る
$ docker exec -it heuristic_hermann bash

# Rockerコンテナ内で
$ sudo ip link set multicast on lo
$ cd /aichallenge
$ bash build.sh
$ source aichallenge_ws/install/setup.bash
$ ros2 launch autoware_launch e2e_simulator.launch.xml vehicle_model:=golfcart sensor_model:=awsim_sensor_kit map_path:=/aichallenge/mapfile

公式ページと同様に画面が表示され、環境構築完了。

ローカル環境での実行

参考ページと同様です。1回のみ実行すればいいコードはここでは記載していません。

#aichallenge2023-simディレクトリで
$ cd docker
$ bash run_container.sh    # Dockerコンテナの起動
  • AWSIM起動
$ /aichallenge/AWSIM/AWSIM.x86_64
  • Autoware起動
    ターミナルを開いて
$ docker exec -it [] bash
# Rockerコンテナ内で
$ cd /aichallenge
$ bash run.sh             # コードの実行

デフォルトでは、自動運転で走り始めた後、ここで止まりました
image.png

6
4
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4