From 21d434f608ab48371b952d138d7f5d1bb4e37495 Mon Sep 17 00:00:00 2001 From: Balakumar Sundaralingam Date: Sat, 4 Nov 2023 15:51:59 -0700 Subject: [PATCH] improve docker scripts (#23) * Feature/support x86 64 (#22) * [Add] support for x86_64 archtecture. * make script executable * [fix] apply shellcheck suggestions (to get rid of warning during runtime) * [fix] update the image_tag to match the x86 tag * add input detection as optional, rename scripts --------- Co-authored-by: Austin Gregg-Smith --- docker/build_dev_docker.sh | 25 ++++++-- docker/build_docker.sh | 73 +++++++++++++++++++++++ docker/build_user_docker.sh | 0 docker/start_dev_docker.sh | 29 +++++++-- docker/start_docker.sh | 28 ++++++--- docker/start_docker_aarch64.sh | 0 docker/start_docker_arm64.sh | 22 ------- docker/start_docker_isaac_sim.sh | 0 docker/start_docker_isaac_sim_headless.sh | 0 docker/start_docker_x86.sh | 0 docker/start_docker_x86_robot.sh | 24 -------- docker/start_user_docker.sh | 65 ++++++++++++++++++++ 12 files changed, 201 insertions(+), 65 deletions(-) mode change 100644 => 100755 docker/build_dev_docker.sh create mode 100755 docker/build_docker.sh mode change 100644 => 100755 docker/build_user_docker.sh mode change 100644 => 100755 docker/start_dev_docker.sh mode change 100644 => 100755 docker/start_docker.sh mode change 100644 => 100755 docker/start_docker_aarch64.sh delete mode 100644 docker/start_docker_arm64.sh mode change 100644 => 100755 docker/start_docker_isaac_sim.sh mode change 100644 => 100755 docker/start_docker_isaac_sim_headless.sh mode change 100644 => 100755 docker/start_docker_x86.sh delete mode 100644 docker/start_docker_x86_robot.sh create mode 100755 docker/start_user_docker.sh diff --git a/docker/build_dev_docker.sh b/docker/build_dev_docker.sh old mode 100644 new mode 100755 index f221fdf..1180a68 --- a/docker/build_dev_docker.sh +++ b/docker/build_dev_docker.sh @@ -12,29 +12,42 @@ # This script will create a dev docker. Run this script by calling `bash build_dev_docker.sh` -# If you want to build a isaac sim docker, run this script with `bash build_dev_docker.sh isaac` +# If you want to build a isaac sim docker, run this script with `bash build_dev_docker.sh isaac_sim_2022.2.1` # Check architecture to build: -arch=`uname -m` +echo "deprecated, use build_docker.sh instead" image_tag="x86" isaac_sim_version="" +input_arg="$1" -if [ $1 == "isaac_sim_2022.2.1" ]; then +if [ -z "$input_arg" ]; then + arch=$(uname -m) + echo "Argument empty, trying to build based on architecture" + if [ "$arch" == "x86_64" ]; then + input_arg="x86" + elif [ "$arch" == "arm64" ]; then + input_arg="aarch64" + elif [ "$arch" == "aarch64" ]; then + input_arg="aarch64" + fi +fi + +if [ "$input_arg" == "isaac_sim_2022.2.1" ]; then echo "Building Isaac Sim docker" dockerfile="isaac_sim.dockerfile" image_tag="isaac_sim_2022.2.1" isaac_sim_version="2022.2.1" -elif [ $1 == "isaac_sim_2023.1.0" ]; then +elif [ "$input_arg" == "isaac_sim_2023.1.0" ]; then echo "Building Isaac Sim headless docker" dockerfile="isaac_sim.dockerfile" image_tag="isaac_sim_2023.1.0" isaac_sim_version="2023.1.0" -elif [ ${arch} == "x86" ]; then +elif [ "$input_arg" == "x86" ]; then echo "Building for X86 Architecture" dockerfile="x86.dockerfile" image_tag="x86" -elif [ ${arch} = "aarch64" ]; then +elif [ "$input_arg" = "aarch64" ]; then echo "Building for ARM Architecture" dockerfile="aarch64.dockerfile" image_tag="aarch64" diff --git a/docker/build_docker.sh b/docker/build_docker.sh new file mode 100755 index 0000000..a58cc9e --- /dev/null +++ b/docker/build_docker.sh @@ -0,0 +1,73 @@ +#!/bin/bash +## +## Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +## +## NVIDIA CORPORATION, its affiliates and licensors retain all intellectual +## property and proprietary rights in and to this material, related +## documentation and any modifications thereto. Any use, reproduction, +## disclosure or distribution of this material and related documentation +## without an express license agreement from NVIDIA CORPORATION or +## its affiliates is strictly prohibited. +## + + +# This script will create a dev docker. Run this script by calling `bash build_dev_docker.sh` +# If you want to build a isaac sim docker, run this script with `bash build_dev_docker.sh isaac_sim_2022.2.1` + +# Check architecture to build: + +image_tag="x86" +isaac_sim_version="" +input_arg="$1" + +if [ -z "$input_arg" ]; then + arch=$(uname -m) + echo "Argument empty, trying to build based on architecture" + if [ "$arch" == "x86_64" ]; then + input_arg="x86" + elif [ "$arch" == "arm64" ]; then + input_arg="aarch64" + elif [ "$arch" == "aarch64" ]; then + input_arg="aarch64" + fi +fi + +if [ "$input_arg" == "isaac_sim_2022.2.1" ]; then + echo "Building Isaac Sim docker" + dockerfile="isaac_sim.dockerfile" + image_tag="isaac_sim_2022.2.1" + isaac_sim_version="2022.2.1" +elif [ "$input_arg" == "isaac_sim_2023.1.0" ]; then + echo "Building Isaac Sim headless docker" + dockerfile="isaac_sim.dockerfile" + image_tag="isaac_sim_2023.1.0" + isaac_sim_version="2023.1.0" +elif [ "$input_arg" == "x86" ]; then + echo "Building for X86 Architecture" + dockerfile="x86.dockerfile" + image_tag="x86" +elif [ "$input_arg" = "aarch64" ]; then + echo "Building for ARM Architecture" + dockerfile="aarch64.dockerfile" + image_tag="aarch64" +else + echo "Unknown Architecture" + exit +fi + +# build docker file: +# Make sure you enable nvidia runtime by: +# Edit/create the /etc/docker/daemon.json with content: +# { +# "runtimes": { +# "nvidia": { +# "path": "/usr/bin/nvidia-container-runtime", +# "runtimeArgs": [] +# } +# }, +# "default-runtime": "nvidia" # ADD this line (the above lines will already exist in your json file) +# } +# +echo "${dockerfile}" + +docker build --build-arg ISAAC_SIM_VERSION=${isaac_sim_version} -t curobo_docker:${image_tag} -f ${dockerfile} . diff --git a/docker/build_user_docker.sh b/docker/build_user_docker.sh old mode 100644 new mode 100755 diff --git a/docker/start_dev_docker.sh b/docker/start_dev_docker.sh old mode 100644 new mode 100755 index 6ea0fdf..999b246 --- a/docker/start_dev_docker.sh +++ b/docker/start_dev_docker.sh @@ -10,8 +10,25 @@ ## its affiliates is strictly prohibited. ## +echo "deprecated, use start_user_docker.sh instead" -if [ $1 == "x86" ]; then +input_arg="$1" + + +if [ -z "$input_arg" ]; then + echo "Argument empty, trying to run based on architecture" + arch=$(uname -m) + if [ "$arch" == "x86_64" ]; then + input_arg="x86" + elif [ "$arch" == "arm64" ]; then + input_arg="aarch64" + elif [ "$arch" == "aarch64" ]; then + input_arg="aarch64" + fi +fi + + +if [ "$input_arg" == "x86" ]; then docker run --rm -it \ --privileged \ @@ -25,9 +42,9 @@ if [ $1 == "x86" ]; then --env DISPLAY=unix$DISPLAY \ --volume /tmp/.X11-unix:/tmp/.X11-unix \ --volume /dev:/dev \ - curobo_docker:user_$1 + curobo_docker:user_$input_arg -elif [ $1 == "aarch64" ]; then +elif [ "$input_arg" == "aarch64" ]; then docker run --rm -it \ --runtime nvidia \ @@ -40,10 +57,10 @@ elif [ $1 == "aarch64" ]; then --volume /tmp/.X11-unix:/tmp/.X11-unix \ --volume /dev/input:/dev/input \ --mount type=bind,src=/home/$USER/code,target=/home/$USER/code \ - curobo_docker:user_$1 + curobo_docker:user_$input_arg -elif [[ $1 == *isaac_sim* ]] ; then - echo "Isaac Sim Dev Docker is not supported" +elif [[ "$input_arg" == *isaac_sim* ]] ; then + echo "Isaac Sim User Docker is not supported" else echo "Unknown docker" fi diff --git a/docker/start_docker.sh b/docker/start_docker.sh old mode 100644 new mode 100755 index 83ed94e..99b63a1 --- a/docker/start_docker.sh +++ b/docker/start_docker.sh @@ -10,7 +10,21 @@ ## its affiliates is strictly prohibited. ## -if [ $1 == "x86" ]; then +input_arg="$1" + +if [ -z "$input_arg" ]; then + echo "Argument empty, trying to run based on architecture" + arch=$(uname -m) + if [ "$arch" == "x86_64" ]; then + input_arg="x86" + elif [ "$arch" == "arm64" ]; then + input_arg="aarch64" + elif [ "$arch" == "aarch64" ]; then + input_arg="aarch64" + fi +fi + +if [ "$input_arg" == "x86" ]; then docker run --rm -it \ --privileged \ @@ -23,9 +37,9 @@ if [ $1 == "x86" ]; then --env DISPLAY=unix$DISPLAY \ --volume /tmp/.X11-unix:/tmp/.X11-unix \ --volume /dev:/dev \ - curobo_docker:$1 + curobo_docker:$input_arg -elif [ $1 == "aarch64" ]; then +elif [ "$input_arg" == "aarch64" ]; then docker run --rm -it \ --runtime nvidia \ @@ -37,11 +51,11 @@ elif [ $1 == "aarch64" ]; then --env DISPLAY=$DISPLAY \ --volume /tmp/.X11-unix:/tmp/.X11-unix \ --volume /dev/input:/dev/input \ - curobo_docker:$1 + curobo_docker:$input_arg -elif [[ $1 == *isaac_sim* ]] ; then +elif [[ "$input_arg" == *isaac_sim* ]] ; then - docker run --name container_$1 --entrypoint bash -it --gpus all -e "ACCEPT_EULA=Y" --rm --network=host \ + docker run --name container_$input_arg --entrypoint bash -it --gpus all -e "ACCEPT_EULA=Y" --rm --network=host \ --privileged \ -e "PRIVACY_CONSENT=Y" \ -v $HOME/.Xauthority:/root/.Xauthority \ @@ -55,7 +69,7 @@ elif [[ $1 == *isaac_sim* ]] ; then -v ~/docker/isaac-sim/data:/root/.local/share/ov/data:rw \ -v ~/docker/isaac-sim/documents:/root/Documents:rw \ --volume /dev:/dev \ - curobo_docker:$1 + curobo_docker:$input_arg else echo "Unknown docker" diff --git a/docker/start_docker_aarch64.sh b/docker/start_docker_aarch64.sh old mode 100644 new mode 100755 diff --git a/docker/start_docker_arm64.sh b/docker/start_docker_arm64.sh deleted file mode 100644 index 96461ae..0000000 --- a/docker/start_docker_arm64.sh +++ /dev/null @@ -1,22 +0,0 @@ -## -## Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -## -## NVIDIA CORPORATION, its affiliates and licensors retain all intellectual -## property and proprietary rights in and to this material, related -## documentation and any modifications thereto. Any use, reproduction, -## disclosure or distribution of this material and related documentation -## without an express license agreement from NVIDIA CORPORATION or -## its affiliates is strictly prohibited. -## -docker run --rm -it \ ---runtime nvidia \ ---mount type=bind,src=/home/$USER/code,target=/home/$USER/code \ ---hostname ros1-docker \ ---add-host ros1-docker:127.0.0.1 \ ---network host \ ---gpus all \ ---env ROS_HOSTNAME=localhost \ ---env DISPLAY=$DISPLAY \ ---volume /tmp/.X11-unix:/tmp/.X11-unix \ ---volume /dev/input:/dev/input \ -curobo_user_docker:latest diff --git a/docker/start_docker_isaac_sim.sh b/docker/start_docker_isaac_sim.sh old mode 100644 new mode 100755 diff --git a/docker/start_docker_isaac_sim_headless.sh b/docker/start_docker_isaac_sim_headless.sh old mode 100644 new mode 100755 diff --git a/docker/start_docker_x86.sh b/docker/start_docker_x86.sh old mode 100644 new mode 100755 diff --git a/docker/start_docker_x86_robot.sh b/docker/start_docker_x86_robot.sh deleted file mode 100644 index a4d7cbf..0000000 --- a/docker/start_docker_x86_robot.sh +++ /dev/null @@ -1,24 +0,0 @@ -## -## Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -## -## NVIDIA CORPORATION, its affiliates and licensors retain all intellectual -## property and proprietary rights in and to this material, related -## documentation and any modifications thereto. Any use, reproduction, -## disclosure or distribution of this material and related documentation -## without an express license agreement from NVIDIA CORPORATION or -## its affiliates is strictly prohibited. -## -docker run --rm -it \ ---privileged --mount type=bind,src=/home/$USER/code,target=/home/$USER/code \ --e NVIDIA_DISABLE_REQUIRE=1 \ --e NVIDIA_DRIVER_CAPABILITIES=all --device /dev/dri \ ---hostname ros1-docker \ ---add-host ros1-docker:127.0.0.1 \ ---gpus all \ ---network host \ ---env ROS_MASTER_URI=http://127.0.0.1:11311 \ ---env ROS_IP=127.0.0.1 \ ---env DISPLAY=unix$DISPLAY \ ---volume /tmp/.X11-unix:/tmp/.X11-unix \ ---volume /dev/input:/dev/input \ -curobo_user_docker:latest \ No newline at end of file diff --git a/docker/start_user_docker.sh b/docker/start_user_docker.sh new file mode 100755 index 0000000..e766198 --- /dev/null +++ b/docker/start_user_docker.sh @@ -0,0 +1,65 @@ +#!/bin/bash +## +## Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +## +## NVIDIA CORPORATION, its affiliates and licensors retain all intellectual +## property and proprietary rights in and to this material, related +## documentation and any modifications thereto. Any use, reproduction, +## disclosure or distribution of this material and related documentation +## without an express license agreement from NVIDIA CORPORATION or +## its affiliates is strictly prohibited. +## + + +input_arg="$1" + + +if [ -z "$input_arg" ]; then + echo "Argument empty, trying to run based on architecture" + arch=$(uname -m) + if [ "$arch" == "x86_64" ]; then + input_arg="x86" + elif [ "$arch" == "arm64" ]; then + input_arg="aarch64" + elif [ "$arch" == "aarch64" ]; then + input_arg="aarch64" + fi +fi + + +if [ "$input_arg" == "x86" ]; then + + docker run --rm -it \ + --privileged \ + -e NVIDIA_DISABLE_REQUIRE=1 \ + -e NVIDIA_DRIVER_CAPABILITIES=all --device /dev/dri \ + --mount type=bind,src=/home/$USER/code,target=/home/$USER/code \ + --hostname ros1-docker \ + --add-host ros1-docker:127.0.0.1 \ + --gpus all \ + --network host \ + --env DISPLAY=unix$DISPLAY \ + --volume /tmp/.X11-unix:/tmp/.X11-unix \ + --volume /dev:/dev \ + curobo_docker:user_$1 + +elif [ "$input_arg" == "aarch64" ]; then + + docker run --rm -it \ + --runtime nvidia \ + --hostname ros1-docker \ + --add-host ros1-docker:127.0.0.1 \ + --network host \ + --gpus all \ + --env ROS_HOSTNAME=localhost \ + --env DISPLAY=$DISPLAY \ + --volume /tmp/.X11-unix:/tmp/.X11-unix \ + --volume /dev/input:/dev/input \ + --mount type=bind,src=/home/$USER/code,target=/home/$USER/code \ + curobo_docker:user_$1 + +elif [[ "$input_arg" == *isaac_sim* ]] ; then + echo "Isaac Sim User Docker is not supported" +else + echo "Unknown docker" +fi