Skip to content

Commit

Permalink
switch nocuda to cuda
Browse files Browse the repository at this point in the history
Signed-off-by: oguzkaganozt <oguzkaganozt@gmail.com>
  • Loading branch information
oguzkaganozt committed Feb 21, 2024
1 parent 6efc27d commit 21fb7c3
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 46 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/docker-build-and-push-main-self-hosted.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ on:
- cron: 0 0 1,15 * *
workflow_dispatch:
inputs:
save-artifacts:
description: Save artifacts to Github Actions
required: true
default: true
type: boolean
artifacts-destination:
type: choice
description: Destination for the artifacts
options:
- registry
- tarball
default: tarball

jobs:
docker-build-and-push-main-self-hosted:
Expand All @@ -36,11 +38,11 @@ jobs:
base_image_env: base_image
lib_dir: aarch64
setup-args: --no-nvidia
additional-tag-suffix: -nocuda
additional-tag-suffix: ""
- name: cuda
base_image_env: base_image
lib_dir: aarch64
additional-tag-suffix: ""
additional-tag-suffix: -cuda
steps:
# https://github.com/actions/checkout/issues/211
- name: Change permission of workspace
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker-build-and-push-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ jobs:
base_image_env: base_image
lib_dir: x86_64
setup-args: --no-nvidia
additional-tag-suffix: -nocuda
additional-tag-suffix: ""
- name: cuda
base_image_env: base_image
lib_dir: x86_64
additional-tag-suffix: ""
additional-tag-suffix: -cuda
steps:
- name: Check out repository
uses: actions/checkout@v4
Expand Down
13 changes: 4 additions & 9 deletions docker/autoware-openadk/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install --no-ins
wget \
cmake \
curl \
gosu \
ccache \
gnupg \
vim \
Expand Down Expand Up @@ -45,9 +46,10 @@ FROM base as prebuilt
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ARG SETUP_ARGS
ENV CMAKE_GENERATOR=Ninja
ENV CCACHE_DIR=/ccache
ARG ROS_DISTRO
ENV CCACHE_DIR=/ccache
ENV CC="/usr/lib/ccache/gcc"
ENV CXX="/usr/lib/ccache/g++"

# Set up development environment
RUN --mount=type=ssh \
Expand All @@ -73,8 +75,6 @@ RUN --mount=type=ssh \
" --no-warn-unused-cli" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
&& find /autoware/install -type d -exec chmod 777 {} \; \
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache \
&& rm -rf /autoware/build /autoware/src
Expand All @@ -90,11 +90,6 @@ RUN --mount=type=ssh \
&& pip uninstall -y ansible ansible-core \
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache

# Instal gosu for switching to local user in entrypoint
RUN --mount=type=ssh \
apt-get update && apt-get install --no-install-recommends -y gosu \
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache

# Change working directory to workspace
WORKDIR /workspace

Expand Down
10 changes: 5 additions & 5 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ parse_arguments() {
set_cuda_options() {
if [ "$option_no_cuda" = "true" ]; then
setup_args="--no-nvidia"
image_name_suffix="-nocuda"
else
image_name_suffix=""
else
image_name_suffix="-cuda"
fi
}

Expand Down Expand Up @@ -119,9 +119,9 @@ build_images() {
--set "*.args.BASE_IMAGE=$base_image" \
--set "*.args.SETUP_ARGS=$setup_args" \
--set "*.args.LIB_DIR=$lib_dir" \
--set "devel.tags=ghcr.io/autowarefoundation/autoware-openadk:latest-devel-$image_name_suffix" \
--set "prebuilt.tags=ghcr.io/autowarefoundation/autoware-openadk:latest-prebuilt-$image_name_suffix" \
--set "runtime.tags=ghcr.io/autowarefoundation/autoware-openadk:latest-runtime-$image_name_suffix" \
--set "devel.tags=ghcr.io/autowarefoundation/autoware-openadk:latest-devel$image_name_suffix" \
--set "prebuilt.tags=ghcr.io/autowarefoundation/autoware-openadk:latest-prebuilt$image_name_suffix" \
--set "runtime.tags=ghcr.io/autowarefoundation/autoware-openadk:latest-runtime$image_name_suffix" \
"${targets[@]}"
set +x
}
Expand Down
51 changes: 28 additions & 23 deletions docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

set -e

# Define terminal colors
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

SCRIPT_DIR=$(readlink -f "$(dirname "$0")")
WORKSPACE_ROOT="$SCRIPT_DIR/../"
source "$WORKSPACE_ROOT/amd64.env"
Expand All @@ -23,18 +29,17 @@ DEFAULT_LAUNCH_CMD="ros2 launch autoware_launch autoware.launch.xml map_path:=/a
# Function to print help message
print_help() {
echo -e "\n------------------------------------------------------------"
echo "Note: The --map-path option is mandatory for default launch command. Please provide exact path to the map files."
echo " Default launch command: ${DEFAULT_LAUNCH_CMD}"
echo "------------------------------------------------------------"
echo "Usage: run.sh [OPTIONS] [LAUNCH_CMD](optional)"
echo "Options:"
echo " --help Display this help message"
echo " -h Display this help message"
echo " --map-path Specify the path to the map files (mandatory if no custom launch command is provided)"
echo " --no-nvidia Disable NVIDIA GPU support"
echo " --devel Use the latest development version of Autoware"
echo " --headless Run Autoware in headless mode (default: false)"
echo " --workspace Specify the workspace path to mount into container(default: current directory)"
echo -e "${RED}Note:${NC} The --map-path option is mandatory if not custom launch command given. Please provide exact path to the map files."
echo -e " Default launch command: ${GREEN}${DEFAULT_LAUNCH_CMD}${NC}"
echo -e "------------------------------------------------------------"
echo -e "${RED}Usage:${NC} run.sh [OPTIONS] [LAUNCH_CMD](optional)"
echo -e "Options:"
echo -e " ${GREEN}--help/-h${NC} Display this help message"
echo -e " ${GREEN}--map-path${NC} Specify the path to the map files (mandatory if no custom launch command is provided)"
echo -e " ${GREEN}--no-nvidia${NC} Disable NVIDIA GPU support"
echo -e " ${GREEN}--devel${NC} Use the latest development version of Autoware"
echo -e " ${GREEN}--headless${NC} Run Autoware in headless mode (default: false)"
echo -e " ${GREEN}--workspace${NC} Specify the workspace path to mount into container"
echo ""
}

Expand Down Expand Up @@ -106,19 +111,19 @@ set_variables() {

# Set image based on option
if [ "$option_devel" == "true" ]; then
IMAGE="ghcr.io/autowarefoundation/autoware-openadk:devel-humble-latest-cuda"
IMAGE="ghcr.io/autowarefoundation/autoware-openadk:latest-devel"
else
IMAGE="ghcr.io/autowarefoundation/autoware-openadk:runtime-humble-latest-cuda"
IMAGE="ghcr.io/autowarefoundation/autoware-openadk:latest-runtime"
fi
}

# Set GPU flag based on option
set_gpu_flag() {
if [ "$option_no_nvidia" = "true" ]; then
IMAGE=${IMAGE}-nocuda
GPU_FLAG=""
else
GPU_FLAG="--gpus all"
IMAGE=${IMAGE}-cuda
fi
}

Expand All @@ -139,18 +144,18 @@ main() {
set_gpu_flag
set_x_display

echo -e "\n-----------------------LAUNCHING CONTAINER-----------------------"
echo "IMAGE: ${IMAGE}"
echo "MAP PATH: ${MAP_PATH}"
echo "LAUNCH CMD: ${LAUNCH_CMD}"
echo "WORKSPACE(to mount): ${WORKSPACE_PATH}"
echo "-----------------------------------------------------------------"
echo -e "${GREEN}\n-----------------------LAUNCHING CONTAINER-----------------------"
echo -e "${GREEN}IMAGE:${NC} ${IMAGE}"
echo -e "${GREEN}MAP PATH(mounted):${NC} ${MAP_PATH}:/autoware_map"
echo -e "${GREEN}WORKSPACE(mounted):${NC} ${WORKSPACE_PATH}:/workspace"
echo -e "${GREEN}LAUNCH CMD:${NC} ${LAUNCH_CMD}"
echo -e "${GREEN}-----------------------------------------------------------------${NC}"

# Launch the container
set -x
docker run -it --rm --net=host ${GPU_FLAG} ${USER_ID} ${MOUNT_X} \
docker run -it --rm --net=host --cpu-period="100000" --cpu-quota="2000000" -e ROS_DOMAIN_ID=28 ${GPU_FLAG} ${USER_ID} ${MOUNT_X} \
${WORKSPACE} ${MAP} ${IMAGE} \
${LAUNCH_CMD}
/usr/bin/bash -c "${LAUNCH_CMD}"
}

# Execute the main script
Expand Down

0 comments on commit 21fb7c3

Please sign in to comment.