From 66f255256e2b68a7499eb6357306c7126c9e533b Mon Sep 17 00:00:00 2001 From: oguzkaganozt Date: Wed, 6 Mar 2024 17:08:28 +0300 Subject: [PATCH] Add two flavors for VS containers Signed-off-by: oguzkaganozt --- .devcontainer/{ => base}/Dockerfile | 0 .devcontainer/base/devcontainer.json | 24 +++++++++++++++ .devcontainer/cuda/Dockerfile | 14 +++++++++ .devcontainer/{ => cuda}/devcontainer.json | 2 +- ansible/playbooks/openadk.yaml | 2 +- docker/README.md | 36 ++++++++++++++++------ 6 files changed, 66 insertions(+), 12 deletions(-) rename .devcontainer/{ => base}/Dockerfile (100%) create mode 100644 .devcontainer/base/devcontainer.json create mode 100644 .devcontainer/cuda/Dockerfile rename .devcontainer/{ => cuda}/devcontainer.json (94%) diff --git a/.devcontainer/Dockerfile b/.devcontainer/base/Dockerfile similarity index 100% rename from .devcontainer/Dockerfile rename to .devcontainer/base/Dockerfile diff --git a/.devcontainer/base/devcontainer.json b/.devcontainer/base/devcontainer.json new file mode 100644 index 00000000000..bf5238b4c7a --- /dev/null +++ b/.devcontainer/base/devcontainer.json @@ -0,0 +1,24 @@ +{ + "name": "Autoware", + "build": { + "dockerfile": "Dockerfile" + }, + "remoteUser": "autoware", + "hostRequirements": { + "gpu": true + }, + "runArgs": [ + "--cap-add=SYS_PTRACE", + "--security-opt", + "seccomp=unconfined", + "--net=host", + "--volume=/etc/localtime:/etc/localtime:ro" + ], + "customizations": { + "vscode": { + "settings.json": { + "terminal.integrated.profiles.linux": { "bash": { "path": "/bin/bash" } } + } + } + } +} diff --git a/.devcontainer/cuda/Dockerfile b/.devcontainer/cuda/Dockerfile new file mode 100644 index 00000000000..e0c09f5de29 --- /dev/null +++ b/.devcontainer/cuda/Dockerfile @@ -0,0 +1,14 @@ +FROM ghcr.io/autowarefoundation/autoware-openadk:latest-devel-cuda + +ENV SHELL /bin/bash + +ARG USERNAME=autoware +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +RUN groupadd --gid $USER_GID $USERNAME \ + && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ + && apt-get update \ + && apt-get install -y sudo \ + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ + && chmod 0440 /etc/sudoers.d/$USERNAME diff --git a/.devcontainer/devcontainer.json b/.devcontainer/cuda/devcontainer.json similarity index 94% rename from .devcontainer/devcontainer.json rename to .devcontainer/cuda/devcontainer.json index 1fd21bcaba3..ccae5a61799 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/cuda/devcontainer.json @@ -1,5 +1,5 @@ { - "name": "Autoware", + "name": "Autoware-cuda", "build": { "dockerfile": "Dockerfile" }, diff --git a/ansible/playbooks/openadk.yaml b/ansible/playbooks/openadk.yaml index 145cb7830f3..496b3d8a73b 100644 --- a/ansible/playbooks/openadk.yaml +++ b/ansible/playbooks/openadk.yaml @@ -5,7 +5,7 @@ - name: Verify OS ansible.builtin.fail: msg: Only Ubuntu 22.04 is supported for this branch. Please refer to https://autowarefoundation.github.io/autoware-documentation/main/installation/autoware/source-installation/. - when: ansible_distribution == 'Ubuntu' and ansible_distribution_version != '22.04' + when: ansible_distribution != 'Ubuntu' or ansible_distribution_version != '22.04' - name: Print args ansible.builtin.debug: diff --git a/docker/README.md b/docker/README.md index be79a809cbc..9b90be1df14 100644 --- a/docker/README.md +++ b/docker/README.md @@ -33,7 +33,7 @@ To install without **NVIDIA GPU** support: ## Usage -### Runtime Setup +### Runtime You can use `run.sh` to run the Autoware runtime container with the map data: @@ -59,7 +59,7 @@ Inside the container, you can run the Autoware simulation by following these tut [Rosbag Replay Simulation](../../tutorials/ad-hoc-simulation/rosbag-replay-simulation.md). -### Development Setup +### Development Environment You can use [VS Code Remote Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) to develop Autoware in the containerized environment with ease. Or you can use `run.sh` manually to run the Autoware development container with the workspace mounted. @@ -68,18 +68,34 @@ You can use [VS Code Remote Containers](https://marketplace.visualstudio.com/ite Get the Visual Studio Code's [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension. And reopen the workspace in the container by selecting `Remote-Containers: Reopen in Container` from the Command Palette (`F1`). -By default devcontainer assumes NVIDIA GPU support, you can change this by deleting these lines within `.devcontainer/devcontainer.json`: +Autoware and Autoware-cuda are available containers for development. -```json - "hostRequirements": { - "gpu": true - }, -``` +If you want to use CUDA supported dev container, you need to install the NVIDIA Container Toolkit before opening the workspace in the container: + +```bash +# Add NVIDIA container toolkit GPG key +sudo apt-key adv --fetch-keys https://nvidia.github.io/libnvidia-container/gpgkey +sudo gpg --no-default-keyring --keyring /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg --import /etc/apt/trusted.gpg + +# Add NVIDIA container toolkit repository +echo "deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://nvidia.github.io/libnvidia-container/stable/deb/$(dpkg --print-architecture) /" | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list + +# Update the package list +sudo apt-get update -```json - "--gpus", "all" +# Install NVIDIA Container Toolkit +sudo apt-get install -y nvidia-container-toolkit + +# Add NVIDIA runtime support to docker engine +sudo nvidia-ctk runtime configure --runtime=docker + +# Restart docker daemon +sudo systemctl restart docker ``` +Then, you can use the `Remote-Containers: Reopen in Container` command to open the workspace in the container. + + #### Using `run.sh` for Development ```bash