-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Dockerfile.x86 for building a Docker image with CUDA and PyTorc…
…h support. Added build.sh script for building the Docker image. Added run.sh script for launching a container from the Docker image. Modified turtlesim_example.launch to accept an argument for the RViz configuration file. Modified turtlesim_init.launch to include the turtlebot3_gazebo launch file and spawn the turtlebot3 model. Modified requirements.txt to comment out the cupy package.
- Loading branch information
Showing
6 changed files
with
118 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
FROM nvidia/cuda:11.6.2-cudnn8-devel-ubuntu20.04 | ||
|
||
# Set noninteractive mode for apt-get | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# Preconfigure tzdata | ||
RUN echo "Etc/UTC" > /etc/timezone && \ | ||
ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime && \ | ||
apt-get update && apt-get install -y tzdata && \ | ||
dpkg-reconfigure --frontend noninteractive tzdata | ||
|
||
# Install Python | ||
RUN apt-get update && apt-get install -y \ | ||
python3.8 \ | ||
python3-pip \ | ||
git | ||
|
||
# Install PyTorch | ||
RUN pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 | ||
COPY requirements.txt /tmp/requirements.txt | ||
RUN pip3 install -r /tmp/requirements.txt | ||
|
||
# Install other Python packages | ||
RUN pip3 install cupy-cuda11x scikit-learn | ||
RUN pip3 install 'git+https://github.com/facebookresearch/detectron2.git' | ||
|
||
# Install ROS | ||
RUN apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 | ||
RUN sh -c 'echo "deb http://packages.ros.org/ros/ubuntu focal main" > /etc/apt/sources.list.d/ros-latest.list' | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
ros-noetic-desktop-full | ||
|
||
# Install ROS packages | ||
RUN apt install -y ros-noetic-pybind11-catkin \ | ||
ros-noetic-grid-map-core ros-noetic-grid-map-msgs ros-noetic-grid-map-ros ros-noetic-grid-map-rviz-plugin \ | ||
libopencv-dev \ | ||
libeigen3-dev \ | ||
libgmp-dev \ | ||
libmpfr-dev \ | ||
libboost-all-dev \ | ||
ros-noetic-turtlebot3-gazebo ros-noetic-turtlebot3-teleop \ | ||
ros-noetic-ros-numpy | ||
|
||
RUN pip3 install catkin-tools | ||
ENV TURTLEBOT3_MODEL=waffle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#! /bin/bash | ||
home=`realpath "$(dirname "$0")"/../` | ||
cd $home && sudo docker build -t elevation_mapping_cupy -f docker/Dockerfile.x86 --no-cache . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
IMAGE_NAME="elevation_mapping_cupy:latest" | ||
|
||
# Define environment variables for enabling graphical output for the container. | ||
XSOCK=/tmp/.X11-unix | ||
XAUTH=/tmp/.docker.xauth | ||
if [ ! -f $XAUTH ] | ||
then | ||
touch $XAUTH | ||
xauth_list=$(xauth nlist :0 | sed -e 's/^..../ffff/') | ||
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge - | ||
chmod a+r $XAUTH | ||
fi | ||
|
||
#== | ||
# Launch container | ||
#== | ||
|
||
# Create symlinks to user configs within the build context. | ||
mkdir -p .etc && cd .etc | ||
ln -sf /etc/passwd . | ||
ln -sf /etc/shadow . | ||
ln -sf /etc/group . | ||
cd .. | ||
|
||
# Launch a container from the prebuilt image. | ||
echo "---------------------" | ||
RUN_COMMAND="docker run \ | ||
--volume=$XSOCK:$XSOCK:rw \ | ||
--volume=$XAUTH:$XAUTH:rw \ | ||
--env="QT_X11_NO_MITSHM=1" \ | ||
--env="XAUTHORITY=$XAUTH" \ | ||
--env="DISPLAY=$DISPLAY" \ | ||
--ulimit rtprio=99 \ | ||
--cap-add=sys_nice \ | ||
--privileged \ | ||
--net=host \ | ||
-eHOST_USERNAME=$(whoami) \ | ||
-v$HOME:$HOME \ | ||
-v$(pwd)/.etc/shadow:/etc/shadow \ | ||
-v$(pwd)/.etc/passwd:/etc/passwd \ | ||
-v$(pwd)/.etc/group:/etc/group \ | ||
-v/media:/media \ | ||
--gpus all \ | ||
-it $IMAGE_NAME" | ||
echo -e "[run.sh]: \e[1;32mThe final run command is\n\e[0;35m$RUN_COMMAND\e[0m." | ||
$RUN_COMMAND | ||
echo -e "[run.sh]: \e[1;32mDocker terminal closed.\e[0m" | ||
# --entrypoint=$ENTRYPOINT \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,29 @@ | ||
<launch> | ||
<arg name="use_sim_time" default="true"/> | ||
<arg name="rviz_config" default="$(find elevation_mapping_cupy)/rviz/turtle_semantic_example.rviz"/> | ||
<arg name="model" default="waffle" doc="model type [burger, waffle, waffle_pi]"/> | ||
<arg name="x_pos" default="-2.0"/> | ||
<arg name="y_pos" default="-0.5"/> | ||
<arg name="z_pos" default="0.0"/> | ||
|
||
<param name="/use_sim_time" type="bool" value="$(arg use_sim_time)"/> | ||
|
||
<include file="$(find gazebo_ros)/launch/empty_world.launch"> | ||
<arg name="world_name" value="$(find turtlebot3_gazebo)/worlds/turtlebot3_world.world"/> | ||
<arg name="paused" value="false"/> | ||
<arg name="use_sim_time" value="true"/> | ||
<arg name="gui" value="false"/> | ||
<arg name="headless" value="false"/> | ||
<arg name="debug" value="false"/> | ||
</include> | ||
|
||
<param name="robot_description" command="$(find xacro)/xacro --inorder $(find turtlebot3_description)/urdf/turtlebot3_$(arg model).urdf.xacro" /> | ||
|
||
<!-- Start gazebo simulation. --> | ||
<include file="$(find turtlebot3_gazebo)/launch/turtlebot3_world.launch" /> | ||
<node pkg="gazebo_ros" type="spawn_model" name="spawn_urdf" args="-urdf -model turtlebot3_$(arg model) -x $(arg x_pos) -y $(arg y_pos) -z $(arg z_pos) -param robot_description" /> | ||
|
||
<!-- Publish turtlebot3 tf's. --> | ||
<node pkg="robot_state_publisher" type="robot_state_publisher" name="waffle_state_publisher"/> | ||
|
||
|
||
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rviz_config)"/> | ||
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rviz_config)"/> | ||
|
||
</launch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters