Skip to content

Commit

Permalink
Add Melodic support
Browse files Browse the repository at this point in the history
  • Loading branch information
atasoglou committed Jul 29, 2019
1 parent cc282f1 commit 6796ea3
Show file tree
Hide file tree
Showing 9 changed files with 420 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,28 @@ nvidia_ros_kinetic_cuda10_cudnn7_opencv3: nvidia_ros_kinetic_cuda10_cudnn7 ## [N
docker build -t turlucode/ros-kinetic:cuda10-cudnn7-opencv3 nvidia/kinetic/cuda10/cudnn7/opencv3
@printf "\n\033[92mDocker Image: turlucode/ros-kinetic:cuda10-cudnn7-opencv3\033[0m\n"

## MELODIC

nvidia_ros_melodic: ## [NVIDIA] Build ROS Melodic Container
docker build -t turlucode/ros-melodic:nvidia nvidia/melodic/base
@printf "\n\033[92mDocker Image: turlucode/ros-melodic:nvidia\033[0m\n"

nvidia_ros_melodic_cuda10: nvidia_ros_melodic ## [NVIDIA] Build ROS Melodic Container | (CUDA 10 - no cuDNN)
docker build -t turlucode/ros-melodic:cuda10 nvidia/melodic/cuda10
@printf "\n\033[92mDocker Image: turlucode/ros-melodic:cuda10\033[0m\n"

nvidia_ros_melodic_cuda10-1: nvidia_ros_melodic ## [NVIDIA] Build ROS Melodic Container | (CUDA 10.1 - no cuDNN)
docker build -t turlucode/ros-melodic:cuda10.1 nvidia/melodic/cuda10.1
@printf "\n\033[92mDocker Image: turlucode/ros-melodic:cuda10.1\033[0m\n"

nvidia_ros_melodic_cuda10_cudnn7: nvidia_ros_melodic_cuda10 ## [NVIDIA] Build ROS Melodic Container | (CUDA 10 - cuDNN 7)
docker build -t turlucode/ros-melodic:cuda10-cudnn7 nvidia/melodic/cuda10/cudnn7
@printf "\n\033[92mDocker Image: turlucode/ros-melodic:cuda10-cudnn7\033[0m\n"

nvidia_ros_melodic_cuda10-1_cudnn7: nvidia_ros_melodic_cuda10.1 ## [NVIDIA] Build ROS Melodic Container | (CUDA 10.1 - cuDNN 7)
docker build -t turlucode/ros-melodic:cuda10-cudnn7 nvidia/melodic/cuda10.1/cudnn7
@printf "\n\033[92mDocker Image: turlucode/ros-melodic:cuda10.1-cudnn7\033[0m\n"

## BOUNCY

nvidia_ros_bouncy: ## [NVIDIA] Build ROS2 Bouncy Container
Expand Down
79 changes: 79 additions & 0 deletions nvidia/melodic/base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
FROM nvidia/opengl:1.0-glvnd-runtime-ubuntu18.04

MAINTAINER Athanasios Tasoglou <[email protected]>
LABEL Description="ROS-Melodic-Desktop (Ubuntu 18.04)" Vendor="TurluCode" Version="1.0"
LABEL com.turlucode.ros.version="melodic"

# Install packages without prompting the user to answer any questions
ENV DEBIAN_FRONTEND noninteractive

# Install packages
RUN apt-get update && apt-get install -y \
locales \
lsb-release \
mesa-utils \
git \
subversion \
nano \
terminator \
wget \
curl \
htop \
dbus-x11 \
software-properties-common \
gdb valgrind && \
apt-get clean && rm -rf /var/lib/apt/lists/*

# Install new paramiko (solves ssh issues)
RUN apt-add-repository universe
RUN apt-get update && apt-get install -y python-pip python build-essential && apt-get clean && rm -rf /var/lib/apt/lists/*
RUN /usr/bin/yes | pip install --upgrade pip
RUN /usr/bin/yes | pip install --upgrade virtualenv
RUN /usr/bin/yes | pip install --upgrade paramiko
RUN /usr/bin/yes | pip install --ignore-installed --upgrade numpy protobuf

# Locale
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

# Install OhMyZSH
RUN apt-get update && apt-get install -y zsh && apt-get clean && rm -rf /var/lib/apt/lists/*
RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true
#RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh
RUN chsh -s /usr/bin/zsh root
RUN git clone https://github.com/sindresorhus/pure /root/.oh-my-zsh/custom/pure
RUN ln -s /root/.oh-my-zsh/custom/pure/pure.zsh-theme /root/.oh-my-zsh/custom/
RUN ln -s /root/.oh-my-zsh/custom/pure/async.zsh /root/.oh-my-zsh/custom/
RUN sed -i -e 's/robbyrussell/refined/g' /root/.zshrc

# Terminator Config
RUN mkdir -p /root/.config/terminator/
COPY assets/terminator_config /root/.config/terminator/config
COPY assets/terminator_background.png /root/.config/terminator/background.png

# Install ROS
RUN sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
RUN apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
RUN apt-get update && apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages \
libpcap-dev \
gstreamer1.0-tools libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev \
ros-melodic-desktop-full python-rosinstall python-rosinstall-generator python-wstool build-essential \
ros-melodic-socketcan-bridge \
ros-melodic-geodesy && \
apt-get clean && rm -rf /var/lib/apt/lists/*

# Configure ROS
RUN rosdep init && rosdep update
RUN echo "source /opt/ros/melodic/setup.bash" >> /root/.bashrc
RUN echo "export ROSLAUNCH_SSH_UNKNOWN=1" >> /root/.bashrc
RUN echo "source /opt/ros/melodic/setup.zsh" >> /root/.zshrc
RUN echo "export ROSLAUNCH_SSH_UNKNOWN=1" >> /root/.zshrc

# Entry script - This will also run terminator
COPY assets/entrypoint_setup.sh /
ENTRYPOINT ["/entrypoint_setup.sh"]

# ---
CMD ["terminator"]
119 changes: 119 additions & 0 deletions nvidia/melodic/base/assets/entrypoint_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#! /bin/bash

# Functions
# TOOD: Check if we can use: getent passwd $USER to extract all variables
# TODO: Check for valid inputs, cause now it will go through even with bad inputs
check_envs () {
DOCKER_CUSTOM_USER_OK=true;
if [ -z ${DOCKER_USER_NAME+x} ]; then
DOCKER_CUSTOM_USER_OK=false;
return;
fi

if [ -z ${DOCKER_USER_ID+x} ]; then
DOCKER_CUSTOM_USER_OK=false;
return;
else
if ! [ -z "${DOCKER_USER_ID##[0-9]*}" ]; then
echo -e "\033[1;33mWarning: User-ID should be a number. Falling back to defaults.\033[0m"
DOCKER_CUSTOM_USER_OK=false;
return;
fi
fi

if [ -z ${DOCKER_USER_GROUP_NAME+x} ]; then
DOCKER_CUSTOM_USER_OK=false;
return;
fi

if [ -z ${DOCKER_USER_GROUP_ID+x} ]; then
DOCKER_CUSTOM_USER_OK=false;
return;
else
if ! [ -z "${DOCKER_USER_GROUP_ID##[0-9]*}" ]; then
echo -e "\033[1;33mWarning: Group-ID should be a number. Falling back to defaults.\033[0m"
DOCKER_CUSTOM_USER_OK=false;
return;
fi
fi
}

setup_env_user () {
USER=$1
USER_ID=$2
GROUP=$3
GROUP_ID=$4

## Create user
useradd -m $USER

## Copy zsh/sh configs
cp /root/.profile /home/$USER/
cp /root/.bashrc /home/$USER/
cp /root/.zshrc /home/$USER/
## Copy terminator configs
mkdir -p /home/$USER/.config/terminator
cp /root/.config/terminator/config /home/$USER/.config/terminator/config
cp /root/.config/terminator/background.png /home/$USER/.config/terminator/background.png
cp -rf /root/.oh-my-zsh /home/$USER/
rm -rf /home/$USER/.oh-my-zsh/custom/pure.zsh-theme /home/$USER/.oh-my-zsh/custom/async.zsh
ln -s /home/$USER/.oh-my-zsh/custom/pure/pure.zsh-theme /home/$USER/.oh-my-zsh/custom/
ln -s /home/$USER/.oh-my-zsh/custom/pure/async.zsh /home/$USER/.oh-my-zsh/custom/
sed -i -e 's@ZSH=\"/root@ZSH=\"/home/$USER@g' /home/$USER/.zshrc
# Copy SSH keys & fix owner
if [ -d "/root/.ssh" ]; then
cp -rf /root/.ssh /home/$USER/
chown -R $USER:$GROUP /home/$USER/.ssh
fi

## Fix owner
chown $USER:$GROUP /home/$USER
chown -R $USER:$GROUP /home/$USER/.config
chown $USER:$GROUP /home/$USER/.profile
chown $USER:$GROUP /home/$USER/.bashrc
chown $USER:$GROUP /home/$USER/.zshrc
chown -R $USER:$GROUP /home/$USER/.oh-my-zsh

## This a trick to keep the evnironmental variables of root which is important!
echo "if ! [ \"$DOCKER_USER_NAME\" = \"$(id -un)\" ]; then" >> /root/.bashrc
echo " cd /home/$DOCKER_USER_NAME" >> /root/.bashrc
echo " su $DOCKER_USER_NAME" >> /root/.bashrc
echo "fi" >> /root/.bashrc

echo "if ! [ \"$DOCKER_USER_NAME\" = \"$(id -un)\" ]; then" >> /root/.zshrc
echo " cd /home/$DOCKER_USER_NAME" >> /root/.zshrc
echo " su $DOCKER_USER_NAME" >> /root/.zshrc
echo "fi" >> /root/.zshrc

## Setup Password-file
PASSWDCONTENTS=$(grep -v "^${USER}:" /etc/passwd)
GROUPCONTENTS=$(grep -v -e "^${GROUP}:" -e "^docker:" /etc/group)

(echo "${PASSWDCONTENTS}" && echo "${USER}:x:$USER_ID:$GROUP_ID::/home/$USER:/bin/bash") > /etc/passwd
(echo "${GROUPCONTENTS}" && echo "${GROUP}:x:${GROUP_ID}:") > /etc/group
(if test -f /etc/sudoers ; then echo "${USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers ; fi)
}


# ---Main---

# Create new user
## Check Inputs
check_envs

## Determine user & Setup Environment
if [ $DOCKER_CUSTOM_USER_OK == true ]; then
echo " -->DOCKER_USER Input is set to '$DOCKER_USER_NAME:$DOCKER_USER_ID:$DOCKER_USER_GROUP_NAME:$DOCKER_USER_GROUP_ID'";
echo -e "\033[0;32mSetting up environment for user=$DOCKER_USER_NAME\033[0m"
setup_env_user $DOCKER_USER_NAME $DOCKER_USER_ID $DOCKER_USER_GROUP_NAME $DOCKER_USER_GROUP_ID
else
echo " -->DOCKER_USER* variables not set. Using 'root'.";
echo -e "\033[0;32mSetting up environment for user=root\033[0m"
DOCKER_USER_NAME="root"
fi

# Change shell to zsh
chsh -s /usr/bin/zsh $DOCKER_USER_NAME

# Run CMD from Docker
"$@"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions nvidia/melodic/base/assets/terminator_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[global_config]
title_receive_bg_color = "#64d8ff"
enabled_plugins = TerminalShot, LaunchpadCodeURLHandler, APTURLHandler, Logger, LaunchpadBugURLHandler
title_transmit_bg_color = "#15b0dc"
[keybindings]
[profiles]
[[default]]
use_system_font = False
background_darkness = 0.69
background_type = transparent
background_image = /root/.config/terminator/background.png
scroll_background = False
font = Monospace 12
scrollback_infinite = True
[layouts]
[[default]]
[[[child1]]]
type = Terminal
parent = window0
[[[window0]]]
type = Window
parent = ""
[plugins]
62 changes: 62 additions & 0 deletions nvidia/melodic/cuda10.1/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
FROM turlucode/ros-melodic:nvidia

MAINTAINER Athanasios Tasoglou <[email protected]>
LABEL Description="ROS-Melodic-Desktop with CUDA 10.1 support (Ubuntu 18.04)" Vendor="TurluCode" Version="1.0"

# Install packages without prompting the user to answer any questions
ENV DEBIAN_FRONTEND noninteractive

# CUDA Base-packages
RUN apt-get update && apt-get install -y --no-install-recommends gnupg2 curl ca-certificates && \
curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub | apt-key add - && \
echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /" > /etc/apt/sources.list.d/cuda.list && \
echo "deb https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64 /" > /etc/apt/sources.list.d/nvidia-ml.list && \
rm -rf /var/lib/apt/lists/*

ENV CUDA_VERSION 10.1.168
ENV CUDA_PKG_VERSION 10-1=$CUDA_VERSION-1
LABEL com.turlucode.ros.cuda="${CUDA_VERSION}"

## For libraries in the cuda-compat-* package: https://docs.nvidia.com/cuda/eula/index.html#attachment-a
RUN apt-get update && apt-get install -y --no-install-recommends \
cuda-cudart-$CUDA_PKG_VERSION \
cuda-compat-10-1 && \
ln -s cuda-10.1 /usr/local/cuda && \
rm -rf /var/lib/apt/lists/*

ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64

## nvidia-container-runtime
ENV NVIDIA_VISIBLE_DEVICES all
# ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
ENV NVIDIA_DRIVER_CAPABILITIES all
ENV NVIDIA_REQUIRE_CUDA "cuda>=10.1 brand=tesla,driver>=384,driver<385 brand=tesla,driver>=396,driver<397 brand=tesla,driver>=410,driver<411"


# CUDA Runtime-packages
ENV NCCL_VERSION 2.4.2
LABEL com.turlucode.ros.nccl="${NCCL_VERSION}"

RUN apt-get update && apt-get install -y --no-install-recommends \
cuda-libraries-$CUDA_PKG_VERSION \
cuda-nvtx-$CUDA_PKG_VERSION \
libnccl2=$NCCL_VERSION-1+cuda10.1 && \
apt-mark hold libnccl2 && \
rm -rf /var/lib/apt/lists/*


# CUDA Devel-packages
RUN apt-get update && apt-get install -y --no-install-recommends \
cuda-libraries-dev-$CUDA_PKG_VERSION \
cuda-nvml-dev-$CUDA_PKG_VERSION \
cuda-minimal-build-$CUDA_PKG_VERSION \
cuda-command-line-tools-$CUDA_PKG_VERSION \
libnccl-dev=$NCCL_VERSION-1+cuda10.1 && \
rm -rf /var/lib/apt/lists/*

ENV LIBRARY_PATH /usr/local/cuda/lib64/stubs


# Launch terminator
CMD ["terminator"]
26 changes: 26 additions & 0 deletions nvidia/melodic/cuda10.1/cudnn7/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM turlucode/ros-melodic:cuda10.1

MAINTAINER Athanasios Tasoglou <[email protected]>
LABEL Description="ROS-Melodic-Desktop with CUDA 10.1 and cuDNN 7 support (Ubuntu 18.04)" Vendor="TurluCode" Version="1.0"

# Install packages without prompting the user to answer any questions
ENV DEBIAN_FRONTEND noninteractive

## CUDNN Runtime-packages
ENV CUDNN_VERSION 7.6.0.64
LABEL com.turlucode.ros.cudnn="${CUDNN_VERSION}"

RUN apt-get update && apt-get install -y --no-install-recommends \
libcudnn7=$CUDNN_VERSION-1+cuda10.1 && \
apt-mark hold libcudnn7 && \
rm -rf /var/lib/apt/lists/*

## CUDNN Devel-packages
RUN apt-get update && apt-get install -y --no-install-recommends \
libcudnn7=$CUDNN_VERSION-1+cuda10.1 \
libcudnn7-dev=$CUDNN_VERSION-1+cuda10.1 && \
apt-mark hold libcudnn7 && \
rm -rf /var/lib/apt/lists/*

# Launch terminator
CMD ["terminator"]
Loading

0 comments on commit 6796ea3

Please sign in to comment.