LoginSignup
5
1

自動運転AIチャレンジ2023 シミュレーション大会の環境構築(GPU)

Last updated at Posted at 2023-12-12

はじめに

自動運転AIチャレンジ2023 シミュレーション大会に参加登録したので、自分のノートPCでAWSIMとAutowareの環境構築した手順をまとめる。

基本的にはこちらのSetupマニュアルの手順のまま

環境

項目
CPU Intel® Core™ i7-12700H
GPU GeForce RTX 3050 Ti Mobile
Ubuntu 22.04
Kernel 6.2.0-36-generic
docker 24.0.6
docker compose v2.21.0

環境構築

AWSIMとAutowareは両方Docker上で環境構築し、両方同じDockerコンテナで動かす。

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

自分のPCだとaptでインストールするとうまく動かないので、いつも公式ページから.runファイルをダウンロードしてインストールしている。
.runファイルからインストールする手順は以下の記事を参照。

docker, rocker, gitlfsのインストール

  1. docker のインストール
sudo apt-get update
sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
  • sudoをつけなくてもdockerコマンド使えるようにする
getent group | grep docker
sudo usermod -aG docker $USER
getent group | grep docker

動作確認

docker run hello-world
  1. rockerのインストール
sudo apt-get install python3-rocker
  1. gitlfsのインストール
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfs
git lfs install

nvidia-docker2のインストール

curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update
sudo apt-get install nvidia-docker2
sudo systemctl restart docker.service
  • 動作確認
docker run --rm --runtime=nvidia --gpus all nvidia/cuda:11.6.2-base-ubuntu20.04 nvidia-smi

#最後のコマンドで以下のような出力が出れば成功です。
#(下記はNVIDIAウェブサイトからのコピペです)


# +-----------------------------------------------------------------------------+
# | NVIDIA-SMI 450.51.06    Driver Version: 450.51.06    CUDA Version: 11.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  Tesla T4            On   | 00000000:00:1E.0 Off |                    0 |
# | N/A   34C    P8     9W /  70W |      0MiB / 15109MiB |      0%      Default |
# |                               |                      |                  N/A |
# +-------------------------------+----------------------+----------------------+
# +-----------------------------------------------------------------------------+
# | Processes:                                                                  |
# |  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
# |        ID   ID                                                   Usage      |
# |=============================================================================|
# |  No running processes found                                                 |
# +-----------------------------------------------------------------------------+

AutowareのDockerイメージの準備

  1. docker image入手

ghcrからaichallenge2023のdocker imageをpullする。

docker pull ghcr.io/automotiveaichallenge/aichallenge2023-racing/autoware-universe-no-cuda

imageが出来ているかの確認

$ docker images
REPOSITORY                                                                       TAG                                 IMAGE ID       CREATED          SIZE
ghcr.io/automotiveaichallenge/aichallenge2023-racing/autoware-universe-no-cuda   latest                              9601fc85f1bd   3 weeks ago      7.31GB    
  1. 大会用 Dockerイメージの作成

aichallenge2023-racingのリポジトリをclone

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

大会用 Dockerイメージのbuild

cd aichallenge2023-racing/docker/train
bash build_docker.sh

imageが出来ているか確認
以降はこのaichallenge-train イメージを使う

$ docker images
REPOSITORY                                                                       TAG                           IMAGE ID       CREATED         SIZE
aichallenge-train                                                                latest                        19c8285b8cd2   2 days ago      7.38GB
  1. AWSIMのダウンロード

GoogleDriveから最新のAWSIM.zipをダウンロードし、aichallenge2023-racing/docker/aichallenge内に大会用AWSIM実行ファイルを展開

  1. docker コンテナの起動

rockerにオプションを追加したいので直接rockerコマンドを実行した。

--name aichallenge2023-racing : 分かりやすいようにコンテナに名前をつける

--nocleanup : コンテナ終了時にコンテナが消えないようにする

mkdir -p output
rocker --nvidia --x11 --user --net host --privileged --nocleanup --name aichallenge2023-racing --volume ../aichallenge:/aichallenge -- aichallenge-train

--volume オプションでホストPCの/aichallenge:/aichallenge以下のディレクトリを共有するのでaichallenge以下のファイルを編集する時はホストPC側で編集できる

docker コンテナ内でAutowareのBuild

cd /aichallenge
bash build_autoware.sh

開発に必要そうなツールのインストール

sudo apt update
sudo apt install ros-humble-rqt*
sudo apt install terminator

docker コンテナの終了

コンテナ内でexitを実行、または

docker stop aichallenge2023-racing
  • 2回目以降の起動
docker start aichallenge2023-racing
docker attach aichallenge2023-racing
or
docker exec -it aichallenge2023-racing bash

追記:

この方法では再起動した後docker startすると以下のエラーが出た。

Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/tmp/.dockere5u782qg.xauth" to rootfs at "/tmp/.dockere5u782qg.xauth": mount /tmp/.dockere5u782qg.xauth:/tmp/.dockere5u782qg.xauth (via /proc/self/fd/7), flags: 0x5000: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
Error: failed to start containers: aichallenge2023-racing

結局 rockerを使わないことにした

 docker run -it   --gpus all   --ipc="host"   --net host   --privileged   --name aichallenge2023-racing   -v /etc/localtime:/etc/localtime:ro   -v /home/porizou/aichallenge2023-racing/docker/aichallenge:/aichallenge   -e DISPLAY=$DISPLAY   -v /tmp/.X11-unix:/tmp/.X11-unix  aichallenge-train

AWSIMとAutowareの実行

AWSIMの起動

docker start aichallenge2023-racing
docker attach aichallenge2023-racing

コンテナ内で以下を実行してAWSIMの起動

cd /aichallenge
bash run_awsim.sh 

Autowareの起動

別のターミナルを開いてコンテナに入る。

docker exec -it aichallenge2023-racing bash

コンテナ内で以下を実行してAutowareの起動

cd /aichallenge
bash run_autoware.sh

5
1
1

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
5
1