-
-
Save TillBeemelmanns/77f4fce8fc06ad607a48e80102107617 to your computer and use it in GitHub Desktop.
Nvidia docker with rviz
This file contains hidden or 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
FROM osrf/ros:melodic-desktop-bionic | |
# setup catkin workspace | |
ENV CATKIN_WS=/root/catkin_ws | |
RUN mkdir -p $CATKIN_WS/src | |
WORKDIR $CATKIN_WS/src | |
# clone source code | |
RUN git clone -b melodic-devel https://github.com/ros-visualization/rviz | |
# install build dependacies | |
RUN apt-get -qq update && \ | |
apt-get -qq install -y \ | |
python-catkin-tools && \ | |
rosdep update && \ | |
rosdep install -y \ | |
--from-paths . \ | |
--ignore-src \ | |
--rosdistro ${ROS_DISTRO} \ | |
--as-root=apt:false && \ | |
rm -rf /var/lib/apt/lists/* | |
# build from source | |
WORKDIR $CATKIN_WS | |
ENV TERM xterm | |
ENV PYTHONIOENCODING UTF-8 | |
RUN catkin config \ | |
--extend /opt/ros/$ROS_DISTRO && \ | |
catkin build | |
# --cmake-args -DCMAKE_BUILD_TYPE=Debug | |
# setup entrypoint | |
COPY ./ros_entrypoint.sh / | |
ENTRYPOINT ["/ros_entrypoint.sh"] | |
# set environment variables | |
ENV NVIDIA_VISIBLE_DEVICES ${NVIDIA_VISIBLE_DEVICES:-all} | |
ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics |
This file contains hidden or 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
all: help | |
help: | |
@echo "" | |
@echo "-- Help Menu" | |
@echo "" | |
@echo " 1. make build - build all images" | |
@echo " 1. make clean - remove all images" | |
@echo "" | |
build: | |
@docker build --tagosrf/ros:melodic-rviz . | |
clean: | |
@docker rmi -f osrf/ros:melodic-rviz |
This file contains hidden or 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
#!/bin/bash | |
set -e | |
# setup ros environment | |
source "/opt/ros/$ROS_DISTRO/setup.bash" | |
source "/root/catkin_ws/devel/setup.bash" | |
exec "$@" |
This file contains hidden or 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
#!/usr/bin/env bash | |
# Runs a docker container with the image created by build_demo.bash | |
# Requires | |
# docker | |
# nvidia-docker2 | |
# an X server | |
# Make sure processes in the container can connect to the x server | |
# Necessary so gazebo can create a context for OpenGL rendering (even headless) | |
XAUTH=/tmp/.docker.xauth | |
if [ ! -f $XAUTH ] | |
then | |
xauth_list=$(xauth nlist :0 | sed -e 's/^..../ffff/') | |
if [ ! -z "$xauth_list" ] | |
then | |
echo $xauth_list | xauth -f $XAUTH nmerge - | |
else | |
touch $XAUTH | |
fi | |
chmod a+r $XAUTH | |
fi | |
docker run -it --rm \ | |
--runtime=nvidia \ | |
--env DISPLAY \ | |
--env QT_X11_NO_MITSHM=1 \ | |
--env XAUTHORITY=$XAUTH \ | |
--volume "$XAUTH:$XAUTH" \ | |
--volume "/tmp/.X11-unix:/tmp/.X11-unix" \ | |
osrf/ros:melodic-rviz \ | |
bash -c "roscore & rviz" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment